diff options
author | Joseph Myers <joseph@codesourcery.com> | 2017-08-08 17:14:49 +0000 |
---|---|---|
committer | Joseph Myers <joseph@codesourcery.com> | 2017-08-08 17:14:49 +0000 |
commit | f17a42333f2eb0bd7ef5194167dd52f9770a6680 (patch) | |
tree | 412b74849f8d26ddf201a572a4d1f7f644fe2198 /malloc | |
parent | 0df595b23a829c9169ec418a19eef9006b4ae801 (diff) | |
download | glibc-f17a42333f2eb0bd7ef5194167dd52f9770a6680.zip glibc-f17a42333f2eb0bd7ef5194167dd52f9770a6680.tar.gz glibc-f17a42333f2eb0bd7ef5194167dd52f9770a6680.tar.bz2 |
Do not use __ptr_t.
sys/cdefs.h has a macro __ptr_t, which a few places in glibc use
instead of void *. void * is a well-understood standard type for that
purpose and in a post-C89 context there is no need for a macro for it;
this patch changes those places to use void * directly instead.
Unlike __long_double_t, __ptr_t is widely used outside glibc (or at
least has many hits on codesearch.debian.net). I don't know how many
of those uses would break if sys/cdefs.h ceased to define the macro,
but there's enough risk that this patch leaves the definition and just
removes the uses within glibc; removal of the definition can be
considered separately if desired.
Tested for x86_64, and with build-many-glibcs.py.
* malloc/mcheck.c (old_free_hook): Use void * instead of __ptr_t.
(old_malloc_hook): Likewise.
(old_memalign_hook): Likewise.
(old_realloc_hook): Likewise.
(struct hdr): Likewise.
(flood): Likewise.
(freehook): Likewise.
(mallochook): Likewise.
(memalignhook): Likewise.
(reallochook): Likewise.
(mprobe): Likewise.
* malloc/mtrace.c (mallwatch): Likewise.
(tr_old_free_hook): Likewise.
(tr_old_malloc_hook): Likewise.
(tr_old_realloc_hook): Likewise.
(tr_old_memalign_hook): Likewise.
(tr_where): Likewise.
(lock_and_info): Likewise.
(tr_freehook): Likewise.
(tr_mallochook): Likewise.
(tr_reallochook): Likewise.
(tr_memalignhook): Likewise.
* misc/err.h [!__GNUC_VA_LIST] (__gnuc_va_list): Likewise.
* misc/mmap.c (__mmap): Likewise.
* misc/mmap64.c (__mmap64): Likewise.
* misc/mprotect.c (__mprotect): Likewise.
* misc/msync.c (msync): Likewise.
* misc/munmap.c (__munmap): Likewise.
* posix/posix_madvise.c (posix_madvise): Likewise.
* socket/send.c (__send): Likewise.
* socket/sendto.c (__sendto): Likewise.
* socket/setsockopt.c (__setsockopt): Likewise.
* string/memcmp.c (__ptr_t): Remove macro.
(MEMCMP): Use void * instead of ptr_t.
* string/memrchr.c (__ptr_t): Remove macro.
(__memrchr): Use void * instead of ptr_t.
* sysdeps/mach/hurd/dl-sysdep.c (__mmap): Likewise.
* sysdeps/mach/hurd/mmap.c (__mmap): Likewise.
* sysdeps/mach/hurd/mmap64.c (__mmap64): Likewise.
* sysdeps/mach/mprotect.c (__mprotect): Likewise.
* sysdeps/mach/msync.c (msync): Likewise.
* sysdeps/mach/munmap.c (__munmap): Likewise.
* sysdeps/mips/bits/setjmp.h (struct __jmp_buf_internal_tag):
Likewise.
* sysdeps/posix/getcwd.c (__getcwd): Likewise.
* sysdeps/powerpc/powerpc32/memset.S (memset): Likewise.
* sysdeps/powerpc/powerpc32/power4/memcpy.S (memcpy): Likewise.
* sysdeps/powerpc/powerpc32/power4/memset.S (memset): Likewise.
* sysdeps/powerpc/powerpc32/power6/memcpy.S (memcpy): Likewise.
* sysdeps/powerpc/powerpc32/power6/memset.S (memset): Likewise.
* sysdeps/powerpc/powerpc32/power7/memcpy.S (memcpy): Likewise.
* sysdeps/powerpc/powerpc32/power7/mempcpy.S (__mempcpy):
Likewise.
* sysdeps/powerpc/powerpc32/power7/memset.S (memset): Likewise.
* sysdeps/powerpc/powerpc64/memcpy.S (memcpy): Likewise.
* sysdeps/powerpc/powerpc64/memset.S (memset): Likewise.
* sysdeps/powerpc/powerpc64/power4/memcpy.S (memcpy): Likewise.
* sysdeps/powerpc/powerpc64/power4/memset.S (memset): Likewise.
* sysdeps/powerpc/powerpc64/power6/memcpy.S (memcpy): Likewise.
* sysdeps/powerpc/powerpc64/power6/memset.S (memset): Likewise.
* sysdeps/powerpc/powerpc64/power7/memcpy.S (memcpy): Likewise.
* sysdeps/powerpc/powerpc64/power7/mempcpy.S (__mempcpy):
Likewise.
* sysdeps/powerpc/powerpc64/power7/memset.S (memset): Likewise.
* sysdeps/powerpc/powerpc64/power8/memset.S (memset): Likewise.
* sysdeps/tile/memcmp.c (__ptr_t): Remove macro.
(MEMCMP): Use void * instead of ptr_t.
* sysdeps/unix/sysv/linux/alpha/oldglob.c (old_glob_t): Likewise.
* sysdeps/unix/sysv/linux/mmap.c (__mmap): Likewise.
Diffstat (limited to 'malloc')
-rw-r--r-- | malloc/mcheck.c | 50 | ||||
-rw-r--r-- | malloc/mtrace.c | 58 |
2 files changed, 54 insertions, 54 deletions
diff --git a/malloc/mcheck.c b/malloc/mcheck.c index 5128d68..e195861 100644 --- a/malloc/mcheck.c +++ b/malloc/mcheck.c @@ -28,12 +28,12 @@ #endif /* Old hook values. */ -static void (*old_free_hook)(__ptr_t ptr, const __ptr_t); -static __ptr_t (*old_malloc_hook) (size_t size, const __ptr_t); -static __ptr_t (*old_memalign_hook) (size_t alignment, size_t size, - const __ptr_t); -static __ptr_t (*old_realloc_hook) (__ptr_t ptr, size_t size, - const __ptr_t); +static void (*old_free_hook)(void *ptr, const void *); +static void *(*old_malloc_hook) (size_t size, const void *); +static void *(*old_memalign_hook) (size_t alignment, size_t size, + const void *); +static void *(*old_realloc_hook) (void *ptr, size_t size, + const void *); /* Function to call when something awful happens. */ static void (*abortfunc) (enum mcheck_status); @@ -51,7 +51,7 @@ struct hdr unsigned long int magic; /* Magic number to check header integrity. */ struct hdr *prev; struct hdr *next; - __ptr_t block; /* Real block allocated, for memalign. */ + void *block; /* Real block allocated, for memalign. */ unsigned long int magic2; /* Extra, keeps us doubleword aligned. */ }; @@ -68,9 +68,9 @@ static int pedantic; # include <string.h> # define flood memset #else -static void flood (__ptr_t, int, size_t); +static void flood (void *, int, size_t); static void -flood (__ptr_t ptr, int val, size_t size) +flood (void *ptr, int val, size_t size) { char *cp = ptr; while (size--) @@ -174,7 +174,7 @@ link_blk (struct hdr *hdr) } } static void -freehook (__ptr_t ptr, const __ptr_t caller) +freehook (void *ptr, const void *caller) { if (pedantic) mcheck_check_all (); @@ -197,8 +197,8 @@ freehook (__ptr_t ptr, const __ptr_t caller) __free_hook = freehook; } -static __ptr_t -mallochook (size_t size, const __ptr_t caller) +static void * +mallochook (size_t size, const void *caller) { struct hdr *hdr; @@ -226,13 +226,13 @@ mallochook (size_t size, const __ptr_t caller) hdr->block = hdr; hdr->magic2 = (uintptr_t) hdr ^ MAGICWORD; ((char *) &hdr[1])[size] = MAGICBYTE; - flood ((__ptr_t) (hdr + 1), MALLOCFLOOD, size); - return (__ptr_t) (hdr + 1); + flood ((void *) (hdr + 1), MALLOCFLOOD, size); + return (void *) (hdr + 1); } -static __ptr_t +static void * memalignhook (size_t alignment, size_t size, - const __ptr_t caller) + const void *caller) { struct hdr *hdr; size_t slop; @@ -262,15 +262,15 @@ memalignhook (size_t alignment, size_t size, hdr->size = size; link_blk (hdr); - hdr->block = (__ptr_t) block; + hdr->block = (void *) block; hdr->magic2 = (uintptr_t) block ^ MAGICWORD; ((char *) &hdr[1])[size] = MAGICBYTE; - flood ((__ptr_t) (hdr + 1), MALLOCFLOOD, size); - return (__ptr_t) (hdr + 1); + flood ((void *) (hdr + 1), MALLOCFLOOD, size); + return (void *) (hdr + 1); } -static __ptr_t -reallochook (__ptr_t ptr, size_t size, const __ptr_t caller) +static void * +reallochook (void *ptr, size_t size, const void *caller) { if (size == 0) { @@ -310,11 +310,11 @@ reallochook (__ptr_t ptr, size_t size, const __ptr_t caller) __memalign_hook = old_memalign_hook; __realloc_hook = old_realloc_hook; if (old_realloc_hook != NULL) - hdr = (struct hdr *) (*old_realloc_hook)((__ptr_t) hdr, + hdr = (struct hdr *) (*old_realloc_hook)((void *) hdr, sizeof (struct hdr) + size + 1, caller); else - hdr = (struct hdr *) realloc ((__ptr_t) hdr, + hdr = (struct hdr *) realloc ((void *) hdr, sizeof (struct hdr) + size + 1); __free_hook = freehook; __malloc_hook = mallochook; @@ -330,7 +330,7 @@ reallochook (__ptr_t ptr, size_t size, const __ptr_t caller) ((char *) &hdr[1])[size] = MAGICBYTE; if (size > osize) flood ((char *) (hdr + 1) + osize, MALLOCFLOOD, size - osize); - return (__ptr_t) (hdr + 1); + return (void *) (hdr + 1); } __attribute__ ((noreturn)) @@ -410,7 +410,7 @@ mcheck_pedantic (void (*func) (enum mcheck_status)) } enum mcheck_status -mprobe (__ptr_t ptr) +mprobe (void *ptr) { return mcheck_used ? checkhdr (((struct hdr *) ptr) - 1) : MCHECK_DISABLED; } diff --git a/malloc/mtrace.c b/malloc/mtrace.c index 02c53eb..d6eb497 100644 --- a/malloc/mtrace.c +++ b/malloc/mtrace.c @@ -50,15 +50,15 @@ static char *malloc_trace_buffer; __libc_lock_define_initialized (static, lock); /* Address to breakpoint on accesses to... */ -__ptr_t mallwatch; +void *mallwatch; /* Old hook values. */ -static void (*tr_old_free_hook) (__ptr_t ptr, const __ptr_t); -static __ptr_t (*tr_old_malloc_hook) (size_t size, const __ptr_t); -static __ptr_t (*tr_old_realloc_hook) (__ptr_t ptr, size_t size, - const __ptr_t); -static __ptr_t (*tr_old_memalign_hook) (size_t __alignment, size_t __size, - const __ptr_t); +static void (*tr_old_free_hook) (void *ptr, const void *); +static void *(*tr_old_malloc_hook) (size_t size, const void *); +static void *(*tr_old_realloc_hook) (void *ptr, size_t size, + const void *); +static void *(*tr_old_memalign_hook) (size_t __alignment, size_t __size, + const void *); /* This function is called when the block being alloc'd, realloc'd, or freed has an address matching the variable "mallwatch". In a debugger, @@ -74,7 +74,7 @@ tr_break (void) libc_hidden_def (tr_break) static void internal_function -tr_where (const __ptr_t caller, Dl_info *info) +tr_where (const void *caller, Dl_info *info) { if (caller != NULL) { @@ -87,12 +87,12 @@ tr_where (const __ptr_t caller, Dl_info *info) buf = alloca (len + 6 + 2 * sizeof (void *)); buf[0] = '('; - __stpcpy (_fitoa (caller >= (const __ptr_t) info->dli_saddr - ? caller - (const __ptr_t) info->dli_saddr - : (const __ptr_t) info->dli_saddr - caller, + __stpcpy (_fitoa (caller >= (const void *) info->dli_saddr + ? caller - (const void *) info->dli_saddr + : (const void *) info->dli_saddr - caller, __stpcpy (__mempcpy (buf + 1, info->dli_sname, len), - caller >= (__ptr_t) info->dli_saddr + caller >= (void *) info->dli_saddr ? "+0x" : "-0x"), 16, 0), ")"); @@ -108,7 +108,7 @@ tr_where (const __ptr_t caller, Dl_info *info) } static Dl_info * -lock_and_info (const __ptr_t caller, Dl_info *mem) +lock_and_info (const void *caller, Dl_info *mem) { if (caller == NULL) return NULL; @@ -121,7 +121,7 @@ lock_and_info (const __ptr_t caller, Dl_info *mem) } static void -tr_freehook (__ptr_t ptr, const __ptr_t caller) +tr_freehook (void *ptr, const void *caller) { if (ptr == NULL) return; @@ -146,19 +146,19 @@ tr_freehook (__ptr_t ptr, const __ptr_t caller) __libc_lock_unlock (lock); } -static __ptr_t -tr_mallochook (size_t size, const __ptr_t caller) +static void * +tr_mallochook (size_t size, const void *caller) { - __ptr_t hdr; + void *hdr; Dl_info mem; Dl_info *info = lock_and_info (caller, &mem); __malloc_hook = tr_old_malloc_hook; if (tr_old_malloc_hook != NULL) - hdr = (__ptr_t) (*tr_old_malloc_hook)(size, caller); + hdr = (void *) (*tr_old_malloc_hook)(size, caller); else - hdr = (__ptr_t) malloc (size); + hdr = (void *) malloc (size); __malloc_hook = tr_mallochook; tr_where (caller, info); @@ -173,10 +173,10 @@ tr_mallochook (size_t size, const __ptr_t caller) return hdr; } -static __ptr_t -tr_reallochook (__ptr_t ptr, size_t size, const __ptr_t caller) +static void * +tr_reallochook (void *ptr, size_t size, const void *caller) { - __ptr_t hdr; + void *hdr; if (ptr == mallwatch) tr_break (); @@ -188,9 +188,9 @@ tr_reallochook (__ptr_t ptr, size_t size, const __ptr_t caller) __malloc_hook = tr_old_malloc_hook; __realloc_hook = tr_old_realloc_hook; if (tr_old_realloc_hook != NULL) - hdr = (__ptr_t) (*tr_old_realloc_hook)(ptr, size, caller); + hdr = (void *) (*tr_old_realloc_hook)(ptr, size, caller); else - hdr = (__ptr_t) realloc (ptr, size); + hdr = (void *) realloc (ptr, size); __free_hook = tr_freehook; __malloc_hook = tr_mallochook; __realloc_hook = tr_reallochook; @@ -221,10 +221,10 @@ tr_reallochook (__ptr_t ptr, size_t size, const __ptr_t caller) return hdr; } -static __ptr_t -tr_memalignhook (size_t alignment, size_t size, const __ptr_t caller) +static void * +tr_memalignhook (size_t alignment, size_t size, const void *caller) { - __ptr_t hdr; + void *hdr; Dl_info mem; Dl_info *info = lock_and_info (caller, &mem); @@ -232,9 +232,9 @@ tr_memalignhook (size_t alignment, size_t size, const __ptr_t caller) __memalign_hook = tr_old_memalign_hook; __malloc_hook = tr_old_malloc_hook; if (tr_old_memalign_hook != NULL) - hdr = (__ptr_t) (*tr_old_memalign_hook)(alignment, size, caller); + hdr = (void *) (*tr_old_memalign_hook)(alignment, size, caller); else - hdr = (__ptr_t) memalign (alignment, size); + hdr = (void *) memalign (alignment, size); __memalign_hook = tr_memalignhook; __malloc_hook = tr_mallochook; |