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/mcheck.c | |
parent | 0df595b23a829c9169ec418a19eef9006b4ae801 (diff) | |
download | glibc-f17a42333f2eb0bd7ef5194167dd52f9770a6680.tar.gz glibc-f17a42333f2eb0bd7ef5194167dd52f9770a6680.tar.xz glibc-f17a42333f2eb0bd7ef5194167dd52f9770a6680.zip |
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/mcheck.c')
-rw-r--r-- | malloc/mcheck.c | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/malloc/mcheck.c b/malloc/mcheck.c index 5128d687fa..e195861c98 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; } |