Ilya Zakharevich on Wed, 29 Dec 2004 10:23:09 +0100


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

[PATCH 2.1.6] Re: Yet another _overflow problem


On Mon, Dec 27, 2004 at 04:32:07AM -0800, Ilya Zakharevich wrote:
> I traced the problem with the build of Math::Pari on MacOS to the
> following piece of code:
> 
> src/kernel/none/level0.h :
> 
>   ulong overflow;
>   ulong hiremainder;
> 
> This works only accidentally; in particular, if the default for the C
> compiler is -fno-common, these are global variables which are not
> common/bss, so the linker gets in a lot of trouble with duplicate
> declarations.
> 
> What is the intent of these declarations: to make the variables
> static, or global?  In the latter case, is not it better to replace
> this branch by

A tested patch follows:

--- ./pari-2.1.6/src/kernel/none/level0.h~	Fri Nov  3 13:00:26 2000
+++ ./pari-2.1.6/src/kernel/none/level0.h	Mon Dec 27 13:44:46 2004
@@ -50,8 +50,9 @@ ENDEXTERN
 
 #else
 
-ulong overflow;
-ulong hiremainder;
+#define NEED_OVERFLOW_HIREMAINDER
+extern ulong overflow;
+extern ulong hiremainder;
 
 INLINE long
 addll(ulong x, ulong y)
--- ./pari-2.1.6/src/kernel/none/mp.c~	Tue Jan 29 05:46:23 2002
+++ ./pari-2.1.6/src/kernel/none/mp.c	Mon Dec 27 13:46:30 2004
@@ -22,6 +22,11 @@ Foundation, Inc., 59 Temple Place - Suit
 /* version (#ifdef __M68K__) since they are defined in mp.s   */
 #include "pari.h"
 
+#ifdef NEED_OVERFLOW_HIREMAINDER
+ulong overflow;
+ulong hiremainder;
+#endif
+
 /* NOTE: arguments of "spec" routines (muliispec, addiispec, etc.) aren't
  * GENs but pairs (long *a, long na) representing a list of digits (in basis
  * BITS_IN_LONG) : a[0], ..., a[na-1]. [ In ordre to facilitate splitting: no