]> www.ginac.de Git - cln.git/commitdiff
Support for MSVC.
authorRichard Kreckel <kreckel@ginac.de>
Sat, 9 Apr 2011 08:04:39 +0000 (10:04 +0200)
committerRichard Kreckel <kreckel@ginac.de>
Sat, 9 Apr 2011 08:04:39 +0000 (10:04 +0200)
This patch works around problems MSVC has with extern "C" declarations
inside namespace cln. As a result, it should work with MS 32-bit compiler
version 16.00.30319.01.

Thanks to Jan Rheinländer <jrheinlaender@gmx.de>.

examples/e.cc
include/cln/number.h
src/base/cl_low.h

index 9aa7c632f6c9fca47fef626cf504a92bd0208f8c..53afa55fa5bb96f6863c987eb3a7a0c27784c57a 100644 (file)
@@ -72,13 +72,13 @@ sum_exp1 (uintC a, uintC b, cl_I & first, cl_I & second)
 }
 
 namespace cln {
-  extern cl_LF cl_I_to_LF(const cl_I&, uintC);
+  extern const cl_LF cl_I_to_LF(const cl_I&, uintC);
 }
 
 void
 const_exp1 (cl_LF & result, uintC dec)
 {
-  uintC c = (uintC) (dec * ::log (10));
+  uintC c = (uintC) (dec * ::log (10.0));
   uintC n = dec;
   uintC actuallen = (uintC)(3.321928094 * dec / intDsize);
   n = (uintC) ((n + c) / ::log ((double)n));
index f0c0c8a0cfb2aca97f8a4c1ea9eb2128a16aa3ca..b5ac95f922720d2787265f526c16709e61c5bb86 100644 (file)
 
 // Constructors and assignment operators from C numeric types.
 
+#ifdef _MSC_VER
+// Workaround to force MSVC to tag the symbol with the cln:: namespace
+// When declaring inside an inlined function the symbol is placed in the 
+// global namespace!
+namespace cln {
+extern cl_private_thing cl_I_constructor_from_L (sint32 wert);
+extern cl_private_thing cl_I_constructor_from_UL (uint32 wert);
+extern cl_private_thing cl_I_constructor_from_Q (sint64 wert);
+extern cl_private_thing cl_I_constructor_from_UQ (uint64 wert);
+}
+#endif
+
 #define CL_DEFINE_INT_CONSTRUCTOR(_class_,_type_)  \
 inline _class_::_class_ (const _type_ wert)                            \
 {                                                                      \
index 553f12638db2baa418b9d085f3630175de812dee..c4c25abef757de8cd17da949eb09a08a6b26279b 100644 (file)
@@ -202,7 +202,13 @@ inline uint32 mulu32_unchecked (uint32 arg1, uint32 arg2)
 // > arg1, arg2 : zwei 32-Bit-Zahlen
 // < 2^32*hi+lo : eine 64-Bit-Zahl
   extern "C" uint32 mulu32_ (uint32 arg1, uint32 arg2); // -> Low-Teil
+#ifdef _MSC_VER
+  // Workaround MSVC compiler bug: extern "C" results in wrong symbols, when
+  // declared inside a namespace!
+} extern "C" uint32 mulu32_high; namespace cln {        // -> High-Teil
+#else
   extern "C" uint32 mulu32_high;                        // -> High-Teil
+#endif
 #if defined(__GNUC__) && defined(__m68k__) && !defined(NO_ASM)
   #define mulu32(x,y,hi_zuweisung,lo_zuweisung)  \
     ({ var uint32 _x = (x);       \
@@ -336,7 +342,12 @@ inline uint32 mulu32_unchecked (uint32 arg1, uint32 arg2)
 // > arg1, arg2 : zwei 64-Bit-Zahlen
 // < 2^64*hi+lo : eine 128-Bit-Zahl
   extern "C" uint64 mulu64_ (uint64 arg1, uint64 arg2); // -> Low-Teil
+#ifdef _MSC_VER
+  // Workaround MSVC compiler bug.
+} extern "C" uint64 mulu64_high; namespace cln {        // -> High-Teil
+#else
   extern "C" uint64 mulu64_high;                        // -> High-Teil
+#endif
 #if defined(__GNUC__) && defined(__alpha__) && !defined(NO_ASM)
   #define mulu64(x,y,hi_zuweisung,lo_zuweisung)  \
     ({ var register uint64 _x = (x);   \
@@ -424,8 +435,13 @@ inline uint32 mulu32_unchecked (uint32 arg1, uint32 arg2)
   extern "C" uint32 divu_3216_1616_ (uint32 x, uint16 y); // -> Quotient q, Rest r
 #else
   extern "C" uint16 divu_3216_1616_ (uint32 x, uint16 y); // -> Quotient q
+#ifdef _MSC_VER
+  // Workaround MSVC compiler bug.
+} extern "C" uint16 divu_16_rest; namespace cln {         // -> Rest r
+#else
   extern "C" uint16 divu_16_rest;                         // -> Rest r
 #endif
+#endif
 #if defined(__GNUC__) && defined(__sparc64__) && !defined(NO_ASM)
   #define divu_3216_1616(x,y,q_zuweisung,r_zuweisung)  \
     ({var uint32 __x = (x);        \
@@ -514,7 +530,12 @@ inline uint32 mulu32_unchecked (uint32 arg1, uint32 arg2)
 // < uint16 r: x mod y
 // < x = q*y+r
   extern "C" uint32 divu_3216_3216_ (uint32 x, uint16 y); // -> Quotient q
+#ifdef _MSC_VER
+  // Workaround MSVC compiler bug.
+} extern "C" uint16 divu_16_rest; namespace cln {         // -> Rest r
+#else
   extern "C" uint16 divu_16_rest;                         // -> Rest r
+#endif
 #if defined(__GNUC__) && defined(__sparc64__) && !defined(NO_ASM)
   #define divu_3216_3216(x,y,q_zuweisung,r_zuweisung)  \
     ({var uint32 __x = (x);        \
@@ -564,7 +585,12 @@ inline uint32 mulu32_unchecked (uint32 arg1, uint32 arg2)
 // < uint32 r: x mod y
 // < x = q*y+r
   extern "C" uint32 divu_3232_3232_ (uint32 x, uint32 y); // -> Quotient q
+#ifdef _MSC_VER
+  // Workaround MSVC compiler bug.
+} extern "C" uint32 divu_32_rest; namespace cln {         // -> Rest r
+#else
   extern "C" uint32 divu_32_rest;                         // -> Rest r
+#endif
 #if defined(__GNUC__) && defined(__sparc64__) && !defined(NO_ASM)
   #define divu_3232_3232(x,y,q_zuweisung,r_zuweisung)  \
     ({var uint32 __x = (x);        \
@@ -661,7 +687,12 @@ inline uint32 mulu32_unchecked (uint32 arg1, uint32 arg2)
 // < uint32 r: x mod y
 // < x = q*y+r
   extern "C" uint32 divu_6432_3232_ (uint32 xhi, uint32 xlo, uint32 y); // -> Quotient q
+#ifdef _MSC_VER
+  // Workaround MSVC compiler bug.
+} extern "C" uint32 divu_32_rest; namespace cln {                       // -> Rest r
+#else
   extern "C" uint32 divu_32_rest;                                       // -> Rest r
+#endif
 #if defined(__GNUC__) && defined(__m68k__) && !defined(NO_ASM)
   #define divu_6432_3232(xhi,xlo,y,q_zuweisung,r_zuweisung)  \
     ({var uint32 __xhi = (xhi);                                                \
@@ -944,7 +975,12 @@ inline uint32 mulu32_unchecked (uint32 arg1, uint32 arg2)
   // multiplication is slower or faster than our own divu_6464_6464_ routine.
   // Anyway, call our own routine.
   extern "C" uint64 divu_6464_6464_ (uint64 x, uint64 y); // -> Quotient q
+#ifdef _MSC_VER
+  // Workaround MSVC compiler bug.
+} extern "C" uint64 divu_64_rest; namespace cln {         // -> Rest r
+#else
   extern "C" uint64 divu_64_rest;                         // -> Rest r
+#endif
   #define divu_6464_6464(x,y,q_zuweisung,r_zuweisung)  \
     { q_zuweisung divu_6464_6464_(x,y); r_zuweisung divu_64_rest; }
   #define NEED_VAR_divu_64_rest
@@ -961,7 +997,12 @@ inline uint32 mulu32_unchecked (uint32 arg1, uint32 arg2)
 // < uint64 r: x mod y
 // < x = q*y+r
   extern "C" uint64 divu_12864_6464_ (uint64 xhi, uint64 xlo, uint64 y); // -> Quotient q
+#ifdef _MSC_VER
+  // Workaround MSVC compiler bug.
+} extern "C" uint64 divu_64_rest; namespace cln {                        // -> Rest r
+#else
   extern "C" uint64 divu_64_rest;                                        // -> Rest r
+#endif
 #if defined(__GNUC__) && defined(__x86_64__) && !defined(NO_ASM)
   #define divu_12864_6464(xhi,xlo,y,q_zuweisung,r_zuweisung)  \
     ({var uint64 __xhi = (xhi);                                                \