Permalink
Browse files

zmq[-devel]: fix use of c++11 and c11

  • Loading branch information...
michaelld committed Jan 11, 2019
1 parent a9ae8f3 commit e068f443fcb5a2581091d5f517c3986072a2cb36
@@ -22,14 +22,18 @@ long_description \

if {${name} eq ${subport}} {
github.setup zeromq libzmq 4.3.0 v
revision 1
checksums rmd160 5a360042648ef80f1e43ad9e1f8ca4a65b27c206 \
sha256 92292bb09b77be6259b60636495292e5ee57055b86afde40e3de42db093285cc \
size 784820
revision 2

conflicts zmq-devel zmq22 zmq3
configure.args-append --disable-libunwind --disable-cxx11
configure.args-append --disable-libunwind --disable-cxx11 --disable-c11

patch.pre_args -p1
patchfiles-append patch-cxx11.release.diff
patchfiles-append patch-c11.release.diff

}

# Legacy subport (no longer supported)
@@ -59,11 +63,15 @@ subport zmq-devel {
checksums rmd160 6d0bcf3d23e125413ed3231e9eefa9f0008c6789 \
sha256 bf85d37ed8fb86751aab928b6a57d07ae9507bdcf1b8cd8d84c22f98f7f7806a \
size 788475
revision 0
revision 1

conflicts zmq zmq22 zmq3
configure.args-append --disable-libunwind --disable-cxx11
configure.args-append --disable-libunwind --disable-cxx11 --disable-c11

patch.pre_args -p1
patchfiles-append patch-cxx11.devel.diff
patchfiles-append patch-c11.devel.diff

}

# override github information
@@ -0,0 +1,24 @@
diff --git a/configure.ac b/configure.ac
index 72a134d..2c07a30 100644
--- a/configure.ac
+++ b/configure.ac
@@ -58,7 +58,18 @@ ZMQ_ORIG_CXXFLAGS="${CXXFLAGS:-none}"

# Checks for programs.
AC_PROG_CC
-AX_CHECK_COMPILE_FLAG([-std=gnu11], [CFLAGS+=" -std=gnu11"], [AC_PROG_CC_C99])
+AC_ARG_ENABLE([c11],
+ [AS_HELP_STRING([--enable-c11],
+ [enable C11 for C compiler [default=no]])],
+ [zmq_enable_c11=$enableval],
+ [zmq_enable_c11="no"])
+if test "x$zmq_enable_c11" != "xno"; then
+ AX_CHECK_COMPILE_FLAG([-std=gnu11],
+ [CFLAGS+=" -std=gnu11"],
+ [AC_MSG_ERROR([C11 requested but not supported by the compiler.])])
+else
+ AC_PROG_CC_C99
+fi
AC_PROG_CXX
AX_CODE_COVERAGE
AM_PROG_CC_C_O
@@ -0,0 +1,24 @@
diff --git a/configure.ac b/configure.ac
index 084a04f..5beba99 100644
--- a/configure.ac
+++ b/configure.ac
@@ -56,7 +56,18 @@ ZMQ_ORIG_CXXFLAGS="${CXXFLAGS:-none}"

# Checks for programs.
AC_PROG_CC
-AX_CHECK_COMPILE_FLAG([-std=gnu11], [CFLAGS+=" -std=gnu11"], [AC_PROG_CC_C99])
+AC_ARG_ENABLE([c11],
+ [AS_HELP_STRING([--enable-c11],
+ [enable C11 for C compiler [default=no]])],
+ [zmq_enable_c11=$enableval],
+ [zmq_enable_c11="no"])
+if test "x$zmq_enable_c11" != "xno"; then
+ AX_CHECK_COMPILE_FLAG([-std=gnu11],
+ [CFLAGS+=" -std=gnu11"],
+ [AC_MSG_ERROR([C11 requested but not supported by the compiler.])])
+else
+ AC_PROG_CC_C99
+fi
AC_PROG_CXX
AX_CODE_COVERAGE
AM_PROG_CC_C_O
@@ -1,59 +1,80 @@
--- configure.ac.orig
+++ configure.ac
@@ -59,6 +59,18 @@
AC_PROG_CC
AX_CHECK_COMPILE_FLAG([-std=gnu11], [CFLAGS+=" -std=gnu11"], [AC_PROG_CC_C99])
AC_PROG_CXX
+
+AC_ARG_ENABLE([cxx11],
+ [AS_HELP_STRING([--enable-cxx11],
+ [enable C++11 for C++ compiler [default=no]])],
+ [zmq_enable_cxx11=$enableval],
+ [zmq_enable_cxx11="no"])
+
+if test "x$zmq_enable_cxx11" != "xno"; then
+ AX_CXX_COMPILE_STDCXX_11([ext], [mandatory])
+ AC_DEFINE(ZMQ_USE_CXX11, 1, [Enable C++11])
+fi
+
AX_CODE_COVERAGE
AM_PROG_CC_C_O
AC_PROG_SED
--- src/atomic_counter.hpp.orig
+++ src/atomic_counter.hpp
diff --git a/configure.ac b/configure.ac
index 5c4e1e4..72a134d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -86,7 +86,15 @@ if test "x$enable_force_CXX98_compat" = "xyes"; then
AX_CHECK_COMPILE_FLAG([-Wc++98-compat -Wc++98-compat-pedantic], [CXXFLAGS+=" -Wc++98-compat"], [])
AC_LANG_POP([C++])
else
- AX_CXX_COMPILE_STDCXX_11([ext], [optional])
+ AC_ARG_ENABLE([cxx11],
+ [AS_HELP_STRING([--enable-cxx11],
+ [enable C++11 for C++ compiler [default=no]])],
+ [zmq_enable_cxx11=$enableval],
+ [zmq_enable_cxx11="no"])
+ if test "x$zmq_enable_cxx11" != "xno"; then
+ AX_CXX_COMPILE_STDCXX_11([ext], [mandatory])
+ AC_DEFINE(ZMQ_USE_CXX11, 1, [Enable C++11])
+ fi
fi

# Check whether to build a with debug symbols
diff --git a/perf/benchmark_radix_tree.cpp b/perf/benchmark_radix_tree.cpp
index efc889c..4cfd4e8 100644
--- a/perf/benchmark_radix_tree.cpp
+++ b/perf/benchmark_radix_tree.cpp
@@ -27,7 +27,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

-#if __cplusplus >= 201103L
+#if defined(ZMQ_USE_CXX11)

#include "radix_tree.hpp"
#include "trie.hpp"
diff --git a/src/atomic_counter.hpp b/src/atomic_counter.hpp
index 4f2ff58..298283a 100644
--- a/src/atomic_counter.hpp
+++ b/src/atomic_counter.hpp
@@ -37,7 +37,7 @@
#define ZMQ_ATOMIC_COUNTER_MUTEX
#elif defined ZMQ_HAVE_ATOMIC_INTRINSICS
#define ZMQ_ATOMIC_COUNTER_INTRINSIC
-#elif (defined __cplusplus && __cplusplus >= 201103L) \
+#elif (defined __cplusplus && defined ZMQ_USE_CXX11) \
+#elif defined(ZMQ_USE_CXX11) \
|| (defined _MSC_VER && _MSC_VER >= 1900)
#define ZMQ_ATOMIC_COUNTER_CXX11
#elif (defined __i386__ || defined __x86_64__) && defined __GNUC__
--- src/atomic_ptr.hpp.orig
+++ src/atomic_ptr.hpp
diff --git a/src/atomic_ptr.hpp b/src/atomic_ptr.hpp
index e16259f..36a5879 100644
--- a/src/atomic_ptr.hpp
+++ b/src/atomic_ptr.hpp
@@ -36,7 +36,7 @@
#define ZMQ_ATOMIC_PTR_MUTEX
#elif defined ZMQ_HAVE_ATOMIC_INTRINSICS
#define ZMQ_ATOMIC_PTR_INTRINSIC
-#elif (defined __cplusplus && __cplusplus >= 201103L) \
+#elif (defined __cplusplus && defined ZMQ_USE_CXX11) \
+#elif defined(ZMQ_USE_CXX11) \
|| (defined _MSC_VER && _MSC_VER >= 1900)
#define ZMQ_ATOMIC_PTR_CXX11
#elif (defined __i386__ || defined __x86_64__) && defined __GNUC__
--- src/blob.hpp.orig
+++ src/blob.hpp
diff --git a/src/blob.hpp b/src/blob.hpp
index c14633c..66a5171 100644
--- a/src/blob.hpp
+++ b/src/blob.hpp
@@ -37,7 +37,7 @@
#include <string.h>
#include <algorithm>

-#if __cplusplus >= 201103L || defined(_MSC_VER) && _MSC_VER > 1700
+#if defined(ZMQ_USE_CXX11) || (defined(_MSC_VER) && _MSC_VER > 1700)
+#if defined(ZMQ_USE_CXX11) || defined(_MSC_VER) && _MSC_VER > 1700
#define ZMQ_HAS_MOVE_SEMANTICS
#define ZMQ_MAP_INSERT_OR_EMPLACE(k, v) emplace (k, v)
#define ZMQ_PUSH_OR_EMPLACE_BACK emplace_back
--- src/condition_variable.hpp.orig
+++ src/condition_variable.hpp
diff --git a/src/condition_variable.hpp b/src/condition_variable.hpp
index e5c7224..c316037 100644
--- a/src/condition_variable.hpp
+++ b/src/condition_variable.hpp
@@ -45,7 +45,7 @@
#define _SUPPORT_CONDITION_VARIABLE 0
#endif
@@ -63,3 +84,77 @@
#define _SUPPORT_CONDITION_VARIABLE 1
#else
#define _SUPPORT_CONDITION_VARIABLE 0
diff --git a/src/ctx.cpp b/src/ctx.cpp
index 67acf03..fa168d7 100644
--- a/src/ctx.cpp
+++ b/src/ctx.cpp
@@ -550,7 +550,7 @@ void zmq::ctx_t::unregister_endpoints (socket_base_t *socket_)
end = _endpoints.end ();
it != end;) {
if (it->second.socket == socket_)
-#if __cplusplus >= 201103L
+#if defined(ZMQ_USE_CXX11)
it = _endpoints.erase (it);
#else
_endpoints.erase (it++);
diff --git a/src/mtrie.hpp b/src/mtrie.hpp
index b5ca3ac..52cdeaa 100644
--- a/src/mtrie.hpp
+++ b/src/mtrie.hpp
@@ -32,7 +32,7 @@

#include "generic_mtrie.hpp"

-#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER > 1600)
+#if defined(ZMQ_USE_CXX11) || (defined(_MSC_VER) && _MSC_VER > 1600)
#define ZMQ_HAS_EXTERN_TEMPLATE 1
#else
#define ZMQ_HAS_EXTERN_TEMPLATE 0
diff --git a/src/options.hpp b/src/options.hpp
index b591e96..b3c36b5 100644
--- a/src/options.hpp
+++ b/src/options.hpp
@@ -47,7 +47,7 @@
#include <sys/ucred.h>
#endif

-#if __cplusplus >= 201103L
+#if defined(ZMQ_USE_CXX11)
#include <type_traits>
#endif

@@ -285,7 +285,7 @@ int do_getsockopt (void *const optval_,
template <typename T>
int do_getsockopt (void *const optval_, size_t *const optvallen_, T value_)
{
-#if __cplusplus >= 201103L && (!defined(__GNUC__) || __GNUC__ > 5)
+#if defined(ZMQ_USE_CXX11) && (!defined(__GNUC__) || __GNUC__ > 5)
static_assert (std::is_trivially_copyable<T>::value,
"invalid use of do_getsockopt");
#endif
diff --git a/src/radio.cpp b/src/radio.cpp
index 486732a..9605fff 100644
--- a/src/radio.cpp
+++ b/src/radio.cpp
@@ -126,7 +126,7 @@ void zmq::radio_t::xpipe_terminated (pipe_t *pipe_)
end = _subscriptions.end ();
it != end;) {
if (it->second == pipe_) {
-#if __cplusplus >= 201103L
+#if defined(ZMQ_USE_CXX11)
it = _subscriptions.erase (it);
#else
_subscriptions.erase (it++);
diff --git a/src/random.cpp b/src/random.cpp
index 6a2c7e2..735e352 100644
--- a/src/random.cpp
+++ b/src/random.cpp
@@ -100,7 +100,7 @@ uint32_t zmq::generate_random ()
// configurable via config.h

// TODO this should probably be done via config.h
-#if __cplusplus >= 201103L \
+#if defined(ZMQ_USE_CXX11) \
|| (defined(__cpp_threadsafe_static_init) \
&& __cpp_threadsafe_static_init >= 200806) \
|| (defined(_MSC_VER) && _MSC_VER >= 1900)
Oops, something went wrong.

0 comments on commit e068f44

Please sign in to comment.