bug-gnulib
[Top][All Lists]
Advanced

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

Re: [PATCH gnulib] * lib/malloca.c: Use uintptr_t to convert pointers to


From: Bruno Haible
Subject: Re: [PATCH gnulib] * lib/malloca.c: Use uintptr_t to convert pointers to integers. Fix warnings with MinGW64 x64.
Date: Tue, 24 Jan 2012 13:25:54 +0100
User-agent: KMail/4.7.4 (Linux/3.1.0-1.2-desktop; KDE/4.7.4; x86_64; ; )

Marc-André Lureau wrote:
> +2012-01-24  Marc-André Lureau  <address@hidden>
> +
> +     * lib/malloca.c: Use uintptr_t to convert pointers to
> +     integers. Fix warnings with MinGW64 x64.

Thanks for the patch. However, use of uintptr_t requires inclusion of the
header that defines this type. In POSIX, <stdint.h> or <unistd.h> can be
included to define uintptr_t. Gnulib defines this type only in <stdint.h>
(see tests/test-stdint.c and tests/test-unistd.c). I'm applying this
combined patch:


2012-01-24  Marc-André Lureau  <address@hidden>  (tiny change)
            Bruno Haible  <address@hidden>

        malloca: Avoid warnings on x86_64 mingw64.
        * lib/malloca.c: Include <stdint.h>.
        (mmalloca, freea): Use uintptr_t to convert pointers to integers.
        * modules/malloca (Depends-on): Add stdint.
        * modules/relocatable-prog-wrapper (Depends-on): Likewise.

--- lib/malloca.c.orig  Tue Jan 24 13:18:20 2012
+++ lib/malloca.c       Tue Jan 24 13:14:45 2012
@@ -22,6 +22,8 @@
 /* Specification.  */
 #include "malloca.h"
 
+#include <stdint.h>
+
 #include "verify.h"
 
 /* The speed critical point in this file is freea() applied to an alloca()
@@ -85,7 +87,7 @@
           ((int *) p)[-1] = MAGIC_NUMBER;
 
           /* Enter p into the hash table.  */
-          slot = (unsigned long) p % HASH_TABLE_SIZE;
+          slot = (uintptr_t) p % HASH_TABLE_SIZE;
           ((struct header *) (p - HEADER_SIZE))->next = mmalloca_results[slot];
           mmalloca_results[slot] = p;
 
@@ -118,7 +120,7 @@
         {
           /* Looks like a mmalloca() result.  To see whether it really is one,
              perform a lookup in the hash table.  */
-          size_t slot = (unsigned long) p % HASH_TABLE_SIZE;
+          size_t slot = (uintptr_t) p % HASH_TABLE_SIZE;
           void **chain = &mmalloca_results[slot];
           for (; *chain != NULL;)
             {
--- modules/malloca.orig        Tue Jan 24 13:18:20 2012
+++ modules/malloca     Tue Jan 24 13:15:09 2012
@@ -11,6 +11,7 @@
 
 Depends-on:
 alloca-opt
+stdint
 verify
 
 configure.ac:
--- modules/relocatable-prog-wrapper.orig       Tue Jan 24 13:18:20 2012
+++ modules/relocatable-prog-wrapper    Tue Jan 24 13:16:17 2012
@@ -39,6 +39,7 @@
 pathmax
 ssize_t
 stdbool
+stdint
 stdlib
 unistd
 environ




reply via email to

[Prev in Thread] Current Thread [Next in Thread]