Some glitches in tune/
David Sparks
sparks05 at proton.me
Wed Feb 11 21:01:52 CET 2026
I'm trying to get GMP working under msys2, and it's definitely been
a struggle. I'm still trying to figure out how to pass a detailed
CPU name like "sandybridge" to ./configure without getting filtered
out by config.sub.
But I did come across a couple of issues that are obvious bugs.
(Should bug reports including patches go to -devel, -bugs, or both?)
First, a minor one: printing pointers. Windows in general is
LLP64; "unsigned long" is 32 bits for hysterical raisins even on
64-bit systems. Thus, if you want to cast to an integer, use
"size_t" and "%zx". (Or you can mess with uintptr_t and PRIxPTR
from <inttypes.h>.)
But if you're not too fussy about the appearance, %p is probably
the simplest way:
diff --git a/tune/common.c b/tune/common.c
index b888780ff..8a6645be2 100644
--- a/tune/common.c
+++ b/tune/common.c
@@ -310,8 +310,6 @@ speed_cache_fill (struct speed_params *s)
static struct speed_params prev;
int i;
- /* FIXME: need a better way to get the format string for a pointer */
-
if (speed_option_addrs)
{
int different;
@@ -328,7 +326,7 @@ speed_cache_fill (struct speed_params *s)
{
printf ("dst");
for (i = 0; i < s->dst_num; i++)
- printf (" %08lX", (unsigned long) s->dst[i].ptr);
+ printf (" %08p", (void *)s->dst[i].ptr);
printf (" ");
}
@@ -336,10 +334,10 @@ speed_cache_fill (struct speed_params *s)
{
printf ("src");
for (i = 0; i < s->src_num; i++)
- printf (" %08lX", (unsigned long) s->src[i].ptr);
+ printf (" %08p", (void *) s->src[i].ptr);
printf (" ");
}
- printf (" (cf sp approx %08lX)\n", (unsigned long) &different);
+ printf (" (cf sp approx %08p)\n", (void *) &different);
}
Then there's the second problem. I spent an embarrassing number of
days fighting with cygwin trying to get a working set of headers and
libraries that included getrusage, before I Read The Fine Source and
noticed that it's supposed to be optional; it was just done in a way
that there was no obvious preprocessor trickery near the failing line.
(For anyone who cares, it's mostly using the "x86_64-pc-cygwin-gcc-"
prefixed toolchain, and if you miss anything you'll have one set of
headers trying to link to a totally incompatible set of libraries and,
because cygwin is LP64, anything using a "long" type will explode, but
you will first get strange link errors with internal stdio function
names that are used by macros like getc() and putc().)
Anyway, it was a simple missing underscore, preventing code that
was supposed to be harmless from compiling at all:
diff --git a/tune/time.c b/tune/time.c
index 1fe33a91c..164082029 100644
--- a/tune/time.c
+++ b/tune/time.c
@@ -664,7 +664,7 @@ int
getrusage_backwards_p (void)
{
static int result = -1;
- struct rusage start, prev, next;
+ struct_rusage start, prev, next;
long d;
int i;
More information about the gmp-devel
mailing list