[or-cvs] r8576: Resolve an XXXX: make sure that we are actually on 2s-comple (in tor/trunk: . src/common)
nickm at seul.org
nickm at seul.org
Mon Oct 2 21:00:21 UTC 2006
Author: nickm
Date: 2006-10-02 17:00:20 -0400 (Mon, 02 Oct 2006)
New Revision: 8576
Modified:
tor/trunk/
tor/trunk/configure.in
tor/trunk/src/common/torint.h
Log:
r8844 at totoro: nickm | 2006-10-02 16:32:44 -0400
Resolve an XXXX: make sure that we are actually on 2s-complement hardware.
Property changes on: tor/trunk
___________________________________________________________________
svk:merge ticket from /tor/trunk [r8844] on 96637b51-b116-0410-a10e-9941ebb49b64
Modified: tor/trunk/configure.in
===================================================================
--- tor/trunk/configure.in 2006-10-02 20:10:41 UTC (rev 8575)
+++ tor/trunk/configure.in 2006-10-02 21:00:20 UTC (rev 8576)
@@ -588,6 +588,27 @@
[Define to 1 iff malloc(0) returns a pointer])
fi
+# whether we seem to be in a 2s-complement world.
+if test -z "$CROSS_COMPILE"; then
+AC_CACHE_CHECK([whether we are using 2s-complement arithmetic], tor_cv_twos_complement,
+[AC_RUN_IFELSE([AC_LANG_SOURCE(
+[[int main () { int problem = ((-99) != (~99)+1);
+return problem ? 1 : 0; }]])],
+ [tor_cv_twos_complement=yes],
+ [tor_cv_twos_complement=no],
+ [tor_cv_twos_complement=cross])])
+
+else
+ # Cross-compiling; let's hope that the target isn't raving mad.
+ AC_MSG_NOTICE([Cross-compiling: we'll assume that NULL is represented as a sequence of 0-valued bytes.])
+ tor_cv_twos_complement=yes
+fi
+
+if test $tor_cv_twos_complement = yes; then
+ AC_DEFINE([USING_TWOS_COMPLEMENT], 1,
+ [Define to 1 iff we represent negative integers with two's complement])
+fi
+
# Whether we should use the dmalloc memory allocation debugging library.
AC_MSG_CHECKING(whether to use dmalloc (debug memory allocation library))
AC_ARG_WITH(dmalloc,
Modified: tor/trunk/src/common/torint.h
===================================================================
--- tor/trunk/src/common/torint.h 2006-10-02 20:10:41 UTC (rev 8575)
+++ tor/trunk/src/common/torint.h 2006-10-02 21:00:20 UTC (rev 8576)
@@ -220,9 +220,12 @@
#error "Missing type uint64_t"
#endif
-/* XXXX This assumes a sane (2's-complement) representation. But if you
- * aren't 2's complement, and you don't define LONG_MAX, then you're so
- * bizarre that I want nothing to do with you. */
+/* This assumes a sane (2's-complement) representation. But if you
+ * aren't 2's complement, and you don't define LONG_MAX, then you're so
+ * bizarre that I want nothing to do with you. */
+#ifndef USING_TWOS_COMPLEMENT
+#error "Seems that your platform doesn't use 2's complement arithmetic. Argh."
+#endif
#ifndef LONG_MAX
#if (SIZEOF_LONG == 4)
#define LONG_MAX 0x7fffffffL
More information about the tor-commits
mailing list