[Rivet-svn] rivet: Use autoconf to select correct strerror_r implementation....

Rivet Mercurial rivet at projects.hepforge.org
Mon Oct 16 11:15:02 BST 2017


details:   https://rivet.hepforge.org/hg/rivet/rev/56141fa6804c
branches:  
changeset: 6089:56141fa6804c
user:      David Grellscheid <david.grellscheid at durham.ac.uk>
date:      Mon Oct 16 11:12:49 2017 +0100
description:
Use autoconf to select correct strerror_r implementation. Fixes zstr on OS X.

diffs (46 lines):

--- a/configure.ac	Tue Oct 10 10:37:21 2017 +0100
+++ b/configure.ac	Mon Oct 16 11:12:49 2017 +0100
@@ -54,6 +54,8 @@
 AC_LIBTOOL_DLOPEN
 AC_PROG_LIBTOOL
 
+AC_FUNC_STRERROR_R
+
 ## YODA histogramming library
 AC_CEDAR_LIBRARYANDHEADERS([YODA], , , [AC_MSG_ERROR([YODA is required])])
 YODABINPATH=$YODALIBPATH/../bin
--- a/src/Core/zstr/strict_fstream.hpp	Tue Oct 10 10:37:21 2017 +0100
+++ b/src/Core/zstr/strict_fstream.hpp	Mon Oct 16 11:12:49 2017 +0100
@@ -6,6 +6,8 @@
 #include <cstring>
 #include <string>
 
+#include "Rivet/Config/DummyConfig.hh"
+
 /**
  * This namespace defines wrappers for std::ifstream, std::ofstream, and
  * std::fstream objects. The wrappers perform the following steps:
@@ -27,17 +29,17 @@
     {
         buff = "Unknown error";
     }
-#elif (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && ! _GNU_SOURCE
+#elif STRERROR_R_CHAR_P
+// GNU-specific strerror_r()
+    auto p = strerror_r(errno, &buff[0], buff.size());
+    std::string tmp(p, std::strlen(p));
+    std::swap(buff, tmp);
+#else
 // XSI-compliant strerror_r()
     if (strerror_r(errno, &buff[0], buff.size()) != 0)
     {
         buff = "Unknown error";
     }
-#else
-// GNU-specific strerror_r()
-    auto p = strerror_r(errno, &buff[0], buff.size());
-    std::string tmp(p, std::strlen(p));
-    std::swap(buff, tmp);
 #endif
     buff.resize(buff.find('\0'));
     return buff;


More information about the Rivet-svn mailing list