[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Bug and Fix: GMP_C_RESTRICT fails on VC for IA-64
From: |
librik |
Subject: |
Bug and Fix: GMP_C_RESTRICT fails on VC for IA-64 |
Date: |
Thu, 12 Sep 2002 23:18:34 -0400 (EDT) |
BUG DESCRIPTION:
The GMP_C_RESTRICT autoconf macro causes serious problems on
Visual C++ for Win64. This compiler supports the C99 __restrict
keyword, but also a __declspec(restrict) declaration qualifier.
The approach used by GMP_C_RESTRICT, #defining "restrict" as
a C preprocessor macro whose value is "__restrict", causes a
compile error when __declspec(restrict) appears later. It would
be better to use a unique C macro name such as "gmp_restrict".
BUG EXPLANATION:
VC for Win64 uses the __restrict keyword to specify restricted
pointers. Configure correctly detects this, and then puts the
following line in config.h:
#define restrict __restrict
so that GMP programmers could use the bare "restrict" keyword.
VC for Win64 also has the __declspec(restrict) syntax, used to
specify that a function returns a restricted pointer. For
instance, the declaration for malloc() in the standard compiler
headers is:
__declspec(noalias) __declspec(restrict) void * __cdecl malloc(size_t);
But the config.h macro above causes the "restrict" to be rewritten
as "__restrict", when a standard header file is #included after config.h.
"__declspec(__restrict)" is illegal syntax.
BUG FIX:
The correct solution is to use a unique macro name, like
GMP_RESTRICT, rather than the common keyword "restrict."
This is easy to do, because restrict is not actually used
anywhere in GMP 4.1. (It is in tasks.html as a "bright idea"
for future development.)
I belive this fix can be applied by changing aclocal.m4,
GMP_C_RESTRICT macro, to remove the lines:
if test $gmp_cv_c_restrict = restrict; then
gmp_cv_c_restrict=yes
fi
and, in the following case statement, removing
restrict | yes) ;;
and changing the word "restrict" to, e.g., "GMP_RESTRICT" in
the two AC_DEFINE()s -- but since I don't actually speak M4,
I'll turn it over to you...
- David Librik
address@hidden
- Bug and Fix: GMP_C_RESTRICT fails on VC for IA-64,
librik <=