]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Have autoconf check whether enums are signed.
authorNick Mathewson <nickm@torproject.org>
Thu, 7 Feb 2013 21:29:32 +0000 (16:29 -0500)
committerNick Mathewson <nickm@torproject.org>
Thu, 7 Feb 2013 21:30:32 +0000 (16:30 -0500)
Fixes bug 7727; fix on 0.2.4.10-alpha.

changes/signof_enum
configure.ac
src/common/compat.h
src/win32/orconfig.h

index fc9b9eda29240ac79c8088036f9d31ffc5d73cbf..ba4fb597d72a346df5664efb90a31803e1a5807c 100644 (file)
@@ -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.
index e80e6f612179e49566081dfd2082c722b16247fb..864477b8fc8485f6deeb30e940bbaa3e6a0757de 100644 (file)
@@ -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>
index d2944e6f4826d4a1bd160e5acdd9bbbdf185b051..fa071e5558898b4e792b6db6eec8c25ef86fd3f4 100644 (file)
@@ -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
index 4312d9fbe50638f8cb8510281585b66734cf5644..f5d5cf4460c7d3cb10112dc12c1d94583215af53 100644 (file)
 #define CURVE25519_ENABLED
 #define USE_CURVE25519_DONNA
 
+#define ENUM_VALS_ARE_SIGNED 1