[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/release-0.2.4] Better test program for 128-bit math support



commit 85e7de68bcfe6b137e0d4bb5fbfdc5f4a3db6a2d
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date:   Thu Apr 11 17:52:26 2013 -0400

    Better test program for 128-bit math support
    
    Clang 3.2 does constant-folding and variable substitution to determine
    that the program is equivalent to "return 1".  Splitting the 128-bit
    math into a new function seems sufficient to fix this.
---
 configure.ac |   40 +++++++++++++++++++++++-----------------
 1 files changed, 23 insertions(+), 17 deletions(-)

diff --git a/configure.ac b/configure.ac
index 8a79653..6f40ac4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -663,32 +663,38 @@ if test x$enable_curve25519 != xno; then
       [AC_LANG_PROGRAM([dnl
         #include <stdint.h>
         typedef unsigned uint128_t __attribute__((mode(TI)));
-	], [dnl
-          uint64_t a = ((uint64_t)2000000000) * 1000000000;
-	  uint64_t b = ((uint64_t)1234567890) << 24;
-	  uint128_t c = ((uint128_t)a) * b;
-	  int ok = ((uint64_t)(c>>96)) == 522859 &&
+	int func(uint64_t a, uint64_t b) {
+  	     uint128_t c = ((uint128_t)a) * b;
+             int ok = ((uint64_t)(c>>96)) == 522859 &&
 	           (((uint64_t)(c>>64))&0xffffffffL) == 3604448702L &&
                    (((uint64_t)(c>>32))&0xffffffffL) == 2351960064L &&
                    (((uint64_t)(c))&0xffffffffL) == 0;
+             return ok;
+        }
+	], [dnl
+	  int ok = func( ((uint64_t)2000000000) * 1000000000,
+	  	         ((uint64_t)1234567890) << 24);
           return !ok;
         ])],
 	[tor_cv_can_use_curve25519_donna_c64=yes],
         [tor_cv_can_use_curve25519_donna_c64=no],
 	[AC_COMPILE_IFELSE(
           [AC_LANG_PROGRAM([dnl
-            #include <stdint.h>
-            typedef unsigned uint128_t __attribute__((mode(TI)));
-            ], [dnl
-              uint64_t a = ((uint64_t)2000000000) * 1000000000;
-	      uint64_t b = ((uint64_t)1234567890) << 24;
-	      uint128_t c = ((uint128_t)a) * b;
-	      int ok = ((uint64_t)(c>>96)) == 522859 &&
-	             (((uint64_t)(c>>64))&0xffffffffL) == 3604448702L &&
-                     (((uint64_t)(c>>32))&0xffffffffL) == 2351960064L &&
-                     (((uint64_t)(c))&0xffffffffL) == 0;
-              return !ok;
-            ])],
+        #include <stdint.h>
+        typedef unsigned uint128_t __attribute__((mode(TI)));
+	int func(uint64_t a, uint64_t b) {
+  	     uint128_t c = ((uint128_t)a) * b;
+             int ok = ((uint64_t)(c>>96)) == 522859 &&
+	           (((uint64_t)(c>>64))&0xffffffffL) == 3604448702L &&
+                   (((uint64_t)(c>>32))&0xffffffffL) == 2351960064L &&
+                   (((uint64_t)(c))&0xffffffffL) == 0;
+             return ok;
+        }
+	], [dnl
+	  int ok = func( ((uint64_t)2000000000) * 1000000000,
+	  	         ((uint64_t)1234567890) << 24);
+          return !ok;
+        ])],
             [tor_cv_can_use_curve25519_donna_c64=cross],
 	    [tor_cv_can_use_curve25519_donna_c64=no])])])
 



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits