aboutsummaryrefslogtreecommitdiff
path: root/malloc/mtrace.c
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2017-08-08 17:14:49 +0000
committerJoseph Myers <joseph@codesourcery.com>2017-08-08 17:14:49 +0000
commitf17a42333f2eb0bd7ef5194167dd52f9770a6680 (patch)
tree412b74849f8d26ddf201a572a4d1f7f644fe2198 /malloc/mtrace.c
parent0df595b23a829c9169ec418a19eef9006b4ae801 (diff)
downloadglibc-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/mtrace.c')
-rw-r--r--malloc/mtrace.c58
1 files changed, 29 insertions, 29 deletions
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;