chiark / gitweb /
config: C/C++ level is a bit more CPU-agnostic
authorRichard Kettlewell <rjk@terraraq.org.uk>
Wed, 19 Dec 2012 21:42:39 +0000 (21:42 +0000)
committerRichard Kettlewell <rjk@terraraq.org.uk>
Wed, 19 Dec 2012 21:42:39 +0000 (21:42 +0000)
lib/Fixed128.c
lib/Fixed64.c
lib/arith.h
lib/mandy.h

index 50ab93c..c22b9b6 100644 (file)
@@ -18,7 +18,7 @@
 #include <stdio.h>
 #include <math.h>
 
-#if !HAVE_ASM_AMD64_128
+#if !HAVE_ASM_128
 void Fixed128_add(struct Fixed128 *r, const struct Fixed128 *a, const struct Fixed128 *b) {
   uint64_t s = 0;
   int n;
@@ -29,9 +29,7 @@ void Fixed128_add(struct Fixed128 *r, const struct Fixed128 *a, const struct Fix
     s >>= 32;
   }
 }
-#endif
 
-#if !HAVE_ASM_AMD64_128
 void Fixed128_sub(struct Fixed128 *r, const struct Fixed128 *a, const struct Fixed128 *b) {
   uint64_t s = 1;
   int n;
@@ -42,9 +40,7 @@ void Fixed128_sub(struct Fixed128 *r, const struct Fixed128 *a, const struct Fix
     s >>= 32;
   }
 }
-#endif
 
-#if !HAVE_ASM_AMD64_128
 int Fixed128_neg(struct Fixed128 *r, const struct Fixed128 *a) {
   uint64_t s = 1;
   int n;
@@ -60,9 +56,7 @@ int Fixed128_neg(struct Fixed128 *r, const struct Fixed128 *a) {
   else
     return 0;
 }
-#endif
 
-#if !HAVE_ASM_AMD64_128
 static int Fixed128_mul_unsigned(struct Fixed128 *r, const struct Fixed128 *a, const struct Fixed128 *b) {
   int n, m, i;
   /* Clear result accumulator */
@@ -249,7 +243,7 @@ int Fixed128_eq(const struct Fixed128 *a, const struct Fixed128 *b) {
   return 1;
 }
 
-#if !HAVE_ASM_AMD64_128
+#if !HAVE_ASM_128
 void Fixed128_shl_unsigned(struct Fixed128 *a) {
   int n;
   for(n = NFIXED128 - 1; n > 0; --n)
@@ -258,7 +252,7 @@ void Fixed128_shl_unsigned(struct Fixed128 *a) {
 }
 #endif
 
-#if !HAVE_ASM_AMD64_128
+#if !HAVE_ASM_128
 void Fixed128_shr_unsigned(struct Fixed128 *a) {
     int n;
     for(n = 0; n < NFIXED128 - 1; ++n)
index 2449e99..ac4f320 100644 (file)
@@ -22,7 +22,7 @@
 uint64_t Fixed64_mul_unsigned(uint64_t a, uint64_t b);
 static uint64_t Fixed64_div_unsigned(uint64_t a, uint64_t b);
 
-#if ! HAVE_ASM_AMD64_64
+#if ! HAVE_ASM_64
 Fixed64 Fixed64_mul(Fixed64 a, Fixed64 b) {
   Fixed64 r;
   int sign = 0;
index 4d86215..2a0cc44 100644 (file)
@@ -177,7 +177,7 @@ public:
   }
 
   static count_t iterate(fixed128 zx, fixed128 zy, fixed128 cx, fixed128 cy, int maxiters) {
-#if HAVE_ASM && NFIXED128 == 4
+#if HAVE_ASM_128 && NFIXED128 == 4
     int rawCount = Fixed128_iterate(&zx.f, &zy.f, &cx.f, &cy.f, maxiters);
     if(rawCount == maxiters)
       return rawCount;
@@ -219,7 +219,7 @@ public:
   static count_t iterate(arith_t zxa, arith_t zya, arith_t cxa, arith_t cya,
                          int maxiters) {
     fixed64 zx = zxa, zy = zya, cx = cxa, cy = cya;
-#if HAVE_ASM_AMD64_64
+#if HAVE_ASM_64
     double r2;
     int rawCount = Fixed64_iterate(zx.f, zy.f, cx.f, cy.f, &r2, maxiters);
     if(rawCount == maxiters)
index 3f8d358..d8a95d5 100644 (file)
@@ -54,13 +54,17 @@ typedef unsigned long long uint64_t;
 #else
 #define LIBMANDY_API __declspec(dllimport)
 #endif
-#define HAVE_ASM_AMD64_64 1
-#define HAVE_ASM_AMD64_128 1
+// On Windows: use assembler if possible
+# if _M_AMD64
+#  define HAVE_ASM_64 1
+#  define HAVE_ASM_128 1
+# endif
 #endif
 
+// On Unix: use assembler if requested to by configure script
 #if HAVE_ASM
-# define HAVE_ASM_AMD64_64 1
-# define HAVE_ASM_AMD64_128 1
+# define HAVE_ASM_64 1
+# define HAVE_ASM_128 1
 #endif
 
 #ifndef LIBMANDY_API