summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2013-02-07 16:29:32 -0500
committerNick Mathewson <nickm@torproject.org>2013-02-07 16:30:32 -0500
commit41200b47709bcdaf6f3a66e8453b3d852bd8d2a6 (patch)
tree1d213ccaa9aa0e6a62c201d3d26dc4aa36db09d4
parent0e597471aff206460f02999d6ea9e1e3243ef945 (diff)
downloadtor-41200b47709bcdaf6f3a66e8453b3d852bd8d2a6.tar.gz
tor-41200b47709bcdaf6f3a66e8453b3d852bd8d2a6.zip
Have autoconf check whether enums are signed.
Fixes bug 7727; fix on 0.2.4.10-alpha.
-rw-r--r--changes/signof_enum3
-rw-r--r--configure.ac6
-rw-r--r--src/common/compat.h3
-rw-r--r--src/win32/orconfig.h1
4 files changed, 11 insertions, 2 deletions
diff --git a/changes/signof_enum b/changes/signof_enum
index fc9b9eda29..ba4fb597d7 100644
--- a/changes/signof_enum
+++ b/changes/signof_enum
@@ -2,3 +2,6 @@
- Use Ville Laurikari's implementation of AX_CHECK_SIGN() to determine
the signs of types during autoconf. This is better than our old
approach, which didn't work when cross-compiling.
+ - Detect the sign of enum values, rather than assuming that MSC is the
+ only compiler where enum types are all signed. Fix for bug 7727;
+ bugfix on 0.2.4.10-alpha.
diff --git a/configure.ac b/configure.ac
index e80e6f6121..864477b8fc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -984,6 +984,12 @@ if test "$tor_cv_size_t_signed" = yes; then
AC_MSG_ERROR([You have a signed size_t; that's grossly nonconformant.])
fi
+AX_CHECK_SIGN([enum always],
+ [ AC_DEFINE(ENUM_VALS_ARE_SIGNED, 1, [Define if enum is always signed]) ],
+ [ : ], [
+ enum always { AAA, BBB, CCC };
+])
+
AC_CHECK_SIZEOF(socklen_t, , [AC_INCLUDES_DEFAULT()
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
diff --git a/src/common/compat.h b/src/common/compat.h
index d2944e6f48..fa071e5558 100644
--- a/src/common/compat.h
+++ b/src/common/compat.h
@@ -136,8 +136,7 @@ extern INLINE double U64_TO_DBL(uint64_t x) {
#define DBL_TO_U64(x) ((uint64_t) (x))
#endif
-#if defined(_MSC_VER)
-/* XXXX024 we should instead have a more general check for "Is enum signed?"*/
+#ifdef ENUM_VALS_ARE_SIGNED
#define ENUM_BF(t) unsigned
#else
/** Wrapper for having a bitfield of an enumerated type. Where possible, we
diff --git a/src/win32/orconfig.h b/src/win32/orconfig.h
index 4312d9fbe5..f5d5cf4460 100644
--- a/src/win32/orconfig.h
+++ b/src/win32/orconfig.h
@@ -256,3 +256,4 @@
#define CURVE25519_ENABLED
#define USE_CURVE25519_DONNA
+#define ENUM_VALS_ARE_SIGNED 1