Various patches against gmp-4.3.0

Michiel De Wilde mdewilde.agilent at
Wed May 6 09:43:54 CEST 2009

>   o dont_redefine_restrict_keyword.diffWindows does not like the
   redefinition of "restrict" as it is being used in some win32 headers
> This is in an internal gmp file.  Please explain why this can be a
> problem.

A #define always changes a name on a global scope level. On Windows, some
win32 headers that get included use __declspec(restrict), which is now
changed to __declspec(__restrict), which is invalid. The problem does not
occur if you include the project name into the identifier that is being
redefined: "#define GMP_RESTRICT __restrict" instead of "#define restrict
__restrict" (and replace "restrict" by "GMP_RESTRICT" in the code).

>   o forgotten_extern_C.difffix for where an extra extern
>   "C" is needed
> Why is this needed?

Without the extern "C", the variable "point_string" is subject to C++ name
mangling: on win32 it becomes "?point_string@@3PADA", leaving an unresolved
symbol  "_point_string".

  o much_more_declspecs.diffin order to make a GMP dll and run the

>   testsuite on it, a lot of functions need to be exported in the dll
>   that currently aren't
> I don't see how gmp-impl.h needs this patching.  Please explain!

We test the gmp dll with the full regression test set. These tests are
directly accessing functions declared in gmp-impl.h. If these functions are
not publically exposed in the dll, many tests will fail because they can't
access the functions.
IMO it is worse to disallow the regression suite to run than to expose these
functions publically in the dll (certainly because, by comparison, on
Linux/UNIX every function is visible anyway).

Besides that, the patch also corrects the __GMP_INLINE_PROTOTYPES handling
for mpn_neg_n.

>   o relax_multiple_symbols.difffix for t-locale where the same symbol
>   (don't remember which) appears twice
> This patch looks really strange.  Is this something needed on Windoze?
> (Surely, this would break build on any non-Windoze system.)

Sorry, it is indeed only needed on Windows. Otherwise we get an error for a
multiply-defined "_localeconv". There may be better solutions than this
quick workaround.

>   o replace_strcasecmp.diffstrcasecmp does not exist on Windows, but

   there is an identical alternative: lstrcmpiA
> This sort of patching around individual system brokeness is very
> problematic.  I need to thing about this.

The function "strcasecmp" is not standard C, but a POSIX extension.

>   o repl-vsnprintf.c.difffix for an error in repl-vsnprintf.c
> What error?  Do you have a test case?
I think there was an error with the "tfprintf" test from mpfr that only
appears when your system doesn't have a valid vprintf/vsnprintf (such as on
In the function that is being patched, a "goto next" is called to indicated
the end of a printf formatting item such as the "d" of "%d". A "break"
appears when detecting modifier characters within a formatting item, such as
the ".17" in "%.17f". As a "g" or and "f" is the final character of a
formatting item, there should be a "goto next" and not a "break".

Kind regards,

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the gmp-devel mailing list