]> www.ginac.de Git - cln.git/commitdiff
Force link-time references despite optimizations done by g++.
authorBruno Haible <bruno@clisp.org>
Mon, 6 May 2002 10:29:18 +0000 (10:29 +0000)
committerBruno Haible <bruno@clisp.org>
Mon, 6 May 2002 10:29:18 +0000 (10:29 +0000)
18 files changed:
ChangeLog
include/cln/GV_integer.h
include/cln/GV_number.h
include/cln/SV_number.h
include/cln/SV_ringelt.h
include/cln/dfloat.h
include/cln/ffloat.h
include/cln/integer.h
include/cln/lfloat.h
include/cln/modinteger.h
include/cln/modules.h
include/cln/rational.h
include/cln/real.h
include/cln/ring.h
include/cln/sfloat.h
include/cln/string.h
include/cln/univpoly.h
src/float/base/cl_ieee.h

index 952833838fc8bd1f30b25e78a1dc8bbe678ca736..90fff94c99806ec5209d42e1fc26c6ad71a64db9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,29 @@
 2002-05-05  Bruno Haible  <bruno@clisp.org>
 
+       Force link-time references despite optimizations done by g++ 2.95
+       and newer.
+       * include/cln/modules.h (CL_FORCE_LINK): New macro.
+       * Use CL_FORCE_LINK.
+       * include/cln/GV_integer.h (cl_GV_I_debug_dummy): Likewise.
+       * include/cln/GV_number.h (cl_GV_number_debug_dummy): Likewise.
+       * include/cln/SV_number.h (cl_SV_number_debug_dummy): Likewise.
+       * include/cln/SV_ringelt.h (cl_SV_ringelt_debug_dummy): Likewise.
+       * include/cln/dfloat.h (cl_DF_debug_dummy): Likewise.
+       * include/cln/ffloat.h (cl_FF_classes_dummy, cl_FF_debug_dummy):
+       Likewise.
+       * include/cln/integer.h (cl_I_classes_dummy, cl_I_debug_dummy):
+       Likewise.
+       * include/cln/lfloat.h (cl_LF_debug_dummy): Likewise.
+       * include/cln/modinteger.h (cl_MI_debug_dummy): Likewise.
+       * include/cln/rational.h (cl_RA_debug_dummy): Likewise.
+       * include/cln/real.h (cl_R_debug_dummy): Likewise.
+       * include/cln/ring.h (cl_ring_debug_dummy): Likewise.
+       * include/cln/sfloat.h (cl_SF_classes_dummy, cl_SF_classes_dummy):
+       Likewise.
+       * include/cln/string.h (cl_string_debug_dummy): Likewise.
+       * include/cln/univpoly.h (cl_UP_debug_dummy): Likewise.
+       * src/float/base/cl_ieee.h (cl_ieee_dummy_NNN): Likewise.
+
        Avoid g++ 3.1 warnings.
        * src/base/cl_offsetof.h (offsetof): Redefine each time.
        * src/base/digitseq/cl_DS.h: Include "cl_offsetof.h" after <gmp.h>.
index 502ec784d7f88ee1c04561c78fce9ef7a37ec0ae..e79d3ddcc93a3936975dc56188e07d0bfdbb55d0 100644 (file)
@@ -78,9 +78,7 @@ CL_DEFINE_PRINT_OPERATOR(cl_GV_I)
 // Debugging support.
 #ifdef CL_DEBUG
 extern int cl_GV_I_debug_module;
-static void* const cl_GV_I_debug_dummy[] = { &cl_GV_I_debug_dummy,
-       &cl_GV_I_debug_module
-};
+CL_FORCE_LINK(cl_GV_I_debug_dummy, cl_GV_I_debug_module)
 #endif
 
 }  // namespace cln
index a9892fb3cc26b3dbb672043bd451eddaf6fb17e8..14d899dad985defde7752f82c785fdb02d32cb90 100644 (file)
@@ -40,9 +40,7 @@ extern const cl_GV_number copy (const cl_GV_number&);
 // Debugging support.
 #ifdef CL_DEBUG
 extern int cl_GV_number_debug_module;
-static void* const cl_GV_number_debug_dummy[] = { &cl_GV_number_debug_dummy,
-       &cl_GV_number_debug_module
-};
+CL_FORCE_LINK(cl_GV_number_debug_dummy, cl_GV_number_debug_module)
 #endif
 
 }  // namespace cln
index 64db595ad80f0ed94c9bffabcd703e0215d97818..810f26c9265b273c8625ccd750653d7378fe6cbf 100644 (file)
@@ -52,9 +52,7 @@ inline const cl_SV_number copy (const cl_SV_number& vector)
 // Debugging support.
 #ifdef CL_DEBUG
 extern int cl_SV_number_debug_module;
-static void* const cl_SV_number_debug_dummy[] = { &cl_SV_number_debug_dummy,
-       &cl_SV_number_debug_module
-};
+CL_FORCE_LINK(cl_SV_number_debug_dummy, cl_SV_number_debug_module)
 #endif
 
 }  // namespace cln
index 9d3a5015153b98973cdb43f1bf7288e35ba301a1..d5ac3bb844d1a7a46504423a76474699bc59a057 100644 (file)
@@ -56,9 +56,7 @@ extern void fprint (std::ostream& stream, const cl_ring& R, const cl_SV_ringelt&
 // Debugging support.
 #ifdef CL_DEBUG
 extern int cl_SV_ringelt_debug_module;
-static void* const cl_SV_ringelt_debug_dummy[] = { &cl_SV_ringelt_debug_dummy,
-       &cl_SV_ringelt_debug_module
-};
+CL_FORCE_LINK(cl_SV_ringelt_debug_dummy, cl_SV_ringelt_debug_module)
 #endif
 
 }  // namespace cln
index 57ca98f82c28a3b5351ee134aa16061df70a6354..b70cb88b2b987537c166a48e015d902a61185855 100644 (file)
@@ -297,9 +297,7 @@ extern cl_class cl_class_dfloat;
 // Debugging support.
 #ifdef CL_DEBUG
 extern int cl_DF_debug_module;
-static void* const cl_DF_debug_dummy[] = { &cl_DF_debug_dummy,
-       &cl_DF_debug_module
-};
+CL_FORCE_LINK(cl_DF_debug_dummy, cl_DF_debug_module)
 #endif
 
 }  // namespace cln
index 9782e4dc79743886dfd23f003fb9c480ab33f093..a107a5e3bc36725253c1110967d7ba54a95c8ebf 100644 (file)
@@ -293,18 +293,14 @@ CL_REQUIRE(cl_ieee)
 // Runtime typing support.
 extern cl_class cl_class_ffloat;
 #ifdef CL_WIDE_POINTERS
-static const void* const cl_FF_classes_dummy[] = { &cl_FF_classes_dummy,
-       &cl_class_ffloat
-};
+CL_FORCE_LINK(cl_FF_classes_dummy, cl_class_ffloat)
 #endif
 
 
 // Debugging support.
 #ifdef CL_DEBUG
 extern int cl_FF_debug_module;
-static void* const cl_FF_debug_dummy[] = { &cl_FF_debug_dummy,
-       &cl_FF_debug_module
-};
+CL_FORCE_LINK(cl_FF_debug_dummy, cl_FF_debug_module)
 #endif
 
 }  // namespace cln
index 850cefe8e6d16c23f67d9df831df41f78fdaa7f0..07624fa5e788424367de9013486bcf292b86434f 100644 (file)
@@ -586,17 +586,13 @@ inline cl_I& operator%= (cl_I& x, const cl_I& y) { return x = x % y; }
 // Runtime typing support.
 extern cl_class cl_class_fixnum;
 extern cl_class cl_class_bignum;
-static const void* const cl_I_classes_dummy[] = { &cl_I_classes_dummy,
-       &cl_class_fixnum
-};
+CL_FORCE_LINK(cl_I_classes_dummy, cl_class_fixnum)
 
 
 // Debugging support.
 #ifdef CL_DEBUG
 extern int cl_I_debug_module;
-static void* const cl_I_debug_dummy[] = { &cl_I_debug_dummy,
-       &cl_I_debug_module
-};
+CL_FORCE_LINK(cl_I_debug_dummy, cl_I_debug_module)
 #endif
 
 }  // namespace cln
index 033ed431108bb02a320984f0d498db8e182aafb0..440151bbffc490c39caf3e0db9555e5031f18872 100644 (file)
@@ -403,9 +403,7 @@ extern cl_class cl_class_lfloat;
 // Debugging support.
 #ifdef CL_DEBUG
 extern int cl_LF_debug_module;
-static void* const cl_LF_debug_dummy[] = { &cl_LF_debug_dummy,
-       &cl_LF_debug_module
-};
+CL_FORCE_LINK(cl_LF_debug_dummy, cl_LF_debug_module)
 #endif
 
 }  // namespace cln
index cc613be9f8e03f0c6365fe3c050d9ec978c7a443..d339cba88505d492eb2e8f9f8a293b1e13461e3f 100644 (file)
@@ -456,9 +456,7 @@ inline const cl_MI operator* (const cl_MI& x, const cl_I& y)
 // Debugging support.
 #ifdef CL_DEBUG
 extern int cl_MI_debug_module;
-static void* const cl_MI_debug_dummy[] = { &cl_MI_debug_dummy,
-       &cl_MI_debug_module
-};
+CL_FORCE_LINK(cl_MI_debug_dummy, cl_MI_debug_module)
 #endif
 
 }  // namespace cln
index 22f7c19f426d089fdfad975ae7b747d69d4d647d..b7ff435cacdae2fc26c731ee1e1de9cbbb563f48 100644 (file)
   #define CL_REQUIRE(module)
 #endif
 
+// Sometimes a link time dependency is needed, but without requirements
+// on initialization order.
+//
+// CL_FORCE_LINK(dummy,external_variable)
+// forces a link time reference to the external_variable.
+#include <stdlib.h>
+#if 0
+// This definition does not work.  It gets optimized away by g++ 3.1.
+#define CL_FORCE_LINK(dummy,external_variable) \
+  static const void* const dummy[] = { &dummy, &external_variable };
+#else
+#define CL_FORCE_LINK(dummy,external_variable) \
+  static const                                                         \
+  struct dummy {                                                       \
+    inline dummy () {                                                  \
+      if ((void*) &external_variable == (void*) this)                  \
+        abort();                                                       \
+    }                                                                  \
+  }                                                                    \
+  dummy##_instance;
+#endif
+
 #endif /* _CL_MODULES_H */
index 5992572bd81f71245266bf15eacf9d0653de13d5..fdc5beb57303465c2ecc98d8b1034da030aa1559 100644 (file)
@@ -294,9 +294,7 @@ extern cl_class cl_class_ratio;
 // Debugging support.
 #ifdef CL_DEBUG
 extern int cl_RA_debug_module;
-static void* const cl_RA_debug_dummy[] = { &cl_RA_debug_dummy,
-       &cl_RA_debug_module
-};
+CL_FORCE_LINK(cl_RA_debug_dummy, cl_RA_debug_module)
 #endif
 
 }  // namespace cln
index 5061ced6850e3dde8492ff4d4fbed827fe58393f..f29465f970c917f8cc442a7ee93a5e34138ca969 100644 (file)
@@ -511,9 +511,7 @@ inline const cl_R conjugate (const cl_R& x)
 // Debugging support.
 #ifdef CL_DEBUG
 extern int cl_R_debug_module;
-static void* const cl_R_debug_dummy[] = { &cl_R_debug_dummy,
-       &cl_R_debug_module
-};
+CL_FORCE_LINK(cl_R_debug_dummy, cl_R_debug_module)
 #endif
 
 }  // namespace cln
index 70b6120cace7fc933ee20030e1b2c53c4c80347b..b282cf362daba6e77a80204b62b91e8fa834aa06 100644 (file)
@@ -434,9 +434,7 @@ inline cl_boolean instanceof (const cl_number& x, const cl_number_ring& R)
 // Debugging support.
 #ifdef CL_DEBUG
 extern int cl_ring_debug_module;
-static void* const cl_ring_debug_dummy[] = { &cl_ring_debug_dummy,
-       &cl_ring_debug_module
-};
+CL_FORCE_LINK(cl_ring_debug_dummy, cl_ring_debug_module)
 #endif
 
 }  // namespace cln
index 1f69d90e7d85c85d325d2d782ae66b16f6f83b06..cb3aa96aa3e38dfcae2249d0f9b34f2d06a02b1e 100644 (file)
@@ -288,17 +288,13 @@ inline cl_SF& operator/= (cl_SF& x, const cl_SF& y) { return x = x / y; }
 
 // Runtime typing support.
 extern cl_class cl_class_sfloat;
-static const void* const cl_SF_classes_dummy[] = { &cl_SF_classes_dummy,
-       &cl_class_sfloat
-};
+CL_FORCE_LINK(cl_SF_classes_dummy, cl_class_sfloat)
 
 
 // Debugging support.
 #ifdef CL_DEBUG
 extern int cl_SF_debug_module;
-static void* const cl_SF_debug_dummy[] = { &cl_SF_debug_dummy,
-       &cl_SF_debug_module
-};
+CL_FORCE_LINK(cl_SF_debug_dummy, cl_SF_debug_module)
 #endif
 
 }  // namespace cln
index f413f523febe8850deb520499a2ead3a5f5c74a3..2c4239df169568eb8c02d135a9165aeeb797c587 100644 (file)
@@ -163,9 +163,7 @@ extern cl_class cl_class_string;
 // Debugging support.
 #ifdef CL_DEBUG
 extern int cl_string_debug_module;
-static void* const cl_string_debug_dummy[] = { &cl_string_debug_dummy,
-       &cl_string_debug_module
-};
+CL_FORCE_LINK(cl_string_debug_dummy, cl_string_debug_module)
 #endif
 
 }  // namespace cln
index bfc88ac411f5f2aa386daa08c9d225994eddc663..23bd0336c3e48bda57302ca2c517ba3f0f3eb5a7 100644 (file)
@@ -457,9 +457,7 @@ inline cl_UP::cl_UP ()
 // Debugging support.
 #ifdef CL_DEBUG
 extern int cl_UP_debug_module;
-static void* const cl_UP_debug_dummy[] = { &cl_UP_debug_dummy,
-       &cl_UP_debug_module
-};
+CL_FORCE_LINK(cl_UP_debug_dummy, cl_UP_debug_module)
 #endif
 
 }  // namespace cln
index 355e6670f41fb742e55eac316366978526466993..0081c460697919170345007df7c37d7d44f9472f 100644 (file)
@@ -10,7 +10,7 @@ namespace cln {
 #if (defined(linux) || defined(__linux)) // only needed on Linux
   #define NEED_IEEE_FLOATS()  \
     CL_REQUIRE(cl_ieee)                                                        \
-    static void* const CONCAT(cl_ieee_dummy_,__LINE__) = &cl_ieee_module;
+    CL_FORCE_LINK(CONCAT(cl_ieee_dummy_,__LINE__), cl_ieee_module)
 #else
   #define NEED_IEEE_FLOATS()
 #endif