From f17a42333f2eb0bd7ef5194167dd52f9770a6680 Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Tue, 8 Aug 2017 17:14:49 +0000 Subject: 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. --- sysdeps/mach/hurd/dl-sysdep.c | 6 +++--- sysdeps/mach/hurd/mmap.c | 20 ++++++++++---------- sysdeps/mach/hurd/mmap64.c | 4 ++-- sysdeps/mach/mprotect.c | 2 +- sysdeps/mach/msync.c | 2 +- sysdeps/mach/munmap.c | 2 +- 6 files changed, 18 insertions(+), 18 deletions(-) (limited to 'sysdeps/mach') diff --git a/sysdeps/mach/hurd/dl-sysdep.c b/sysdeps/mach/hurd/dl-sysdep.c index 4f274b4d65..3794aed521 100644 --- a/sysdeps/mach/hurd/dl-sysdep.c +++ b/sysdeps/mach/hurd/dl-sysdep.c @@ -453,8 +453,8 @@ __libc_lseek64 (int fd, off64_t offset, int whence) return offset; } -__ptr_t weak_function -__mmap (__ptr_t addr, size_t len, int prot, int flags, int fd, off_t offset) +void *weak_function +__mmap (void *addr, size_t len, int prot, int flags, int fd, off_t offset) { error_t err; vm_prot_t vmprot; @@ -512,7 +512,7 @@ __mmap (__ptr_t addr, size_t len, int prot, int flags, int fd, off_t offset) if (err) return __hurd_fail (err), MAP_FAILED; - return (__ptr_t) mapaddr; + return (void *) mapaddr; } int weak_function diff --git a/sysdeps/mach/hurd/mmap.c b/sysdeps/mach/hurd/mmap.c index dbd718a688..72706c3332 100644 --- a/sysdeps/mach/hurd/mmap.c +++ b/sysdeps/mach/hurd/mmap.c @@ -26,12 +26,12 @@ is nonzero, it is the desired mapping address. If the MAP_FIXED bit is set in FLAGS, the mapping will be at ADDR exactly (which must be page-aligned); otherwise the system chooses a convenient nearby address. - The return value is the actual mapping address chosen or (__ptr_t) -1 + The return value is the actual mapping address chosen or (void *) -1 for errors (in which case `errno' is set). A successful `mmap' call deallocates any previous mapping for the affected region. */ -__ptr_t -__mmap (__ptr_t addr, size_t len, int prot, int flags, int fd, off_t offset) +void * +__mmap (void *addr, size_t len, int prot, int flags, int fd, off_t offset) { error_t err; vm_prot_t vmprot; @@ -42,7 +42,7 @@ __mmap (__ptr_t addr, size_t len, int prot, int flags, int fd, off_t offset) /* ADDR and OFFSET must be page-aligned. */ if ((mapaddr & (__vm_page_size - 1)) || (offset & (__vm_page_size - 1))) - return (__ptr_t) (long int) __hurd_fail (EINVAL); + return (void *) (long int) __hurd_fail (EINVAL); if ((flags & (MAP_TYPE|MAP_INHERIT)) == MAP_ANON && prot == (PROT_READ|PROT_WRITE)) /* cf VM_PROT_DEFAULT */ @@ -64,7 +64,7 @@ __mmap (__ptr_t addr, size_t len, int prot, int flags, int fd, off_t offset) err = __vm_allocate (__mach_task_self (), &mapaddr, len, 1); } - return err ? (__ptr_t) (long int) __hurd_fail (err) : (__ptr_t) mapaddr; + return err ? (void *) (long int) __hurd_fail (err) : (void *) mapaddr; } vmprot = VM_PROT_NONE; @@ -78,7 +78,7 @@ __mmap (__ptr_t addr, size_t len, int prot, int flags, int fd, off_t offset) switch (flags & MAP_TYPE) { default: - return (__ptr_t) (long int) __hurd_fail (EINVAL); + return (void *) (long int) __hurd_fail (EINVAL); case MAP_ANON: memobj = MACH_PORT_NULL; @@ -92,7 +92,7 @@ __mmap (__ptr_t addr, size_t len, int prot, int flags, int fd, off_t offset) { if (err == MIG_BAD_ID || err == EOPNOTSUPP || err == ENOSYS) err = ENODEV; /* File descriptor doesn't support mmap. */ - return (__ptr_t) (long int) __hurd_dfail (fd, err); + return (void *) (long int) __hurd_dfail (fd, err); } switch (prot & (PROT_READ|PROT_WRITE)) { @@ -129,7 +129,7 @@ __mmap (__ptr_t addr, size_t len, int prot, int flags, int fd, off_t offset) else { __mach_port_deallocate (__mach_task_self (), wobj); - return (__ptr_t) (long int) __hurd_fail (EACCES); + return (void *) (long int) __hurd_fail (EACCES); } break; default: @@ -180,9 +180,9 @@ __mmap (__ptr_t addr, size_t len, int prot, int flags, int fd, off_t offset) __mach_port_deallocate (__mach_task_self (), memobj); if (err) - return (__ptr_t) (long int) __hurd_fail (err); + return (void *) (long int) __hurd_fail (err); - return (__ptr_t) mapaddr; + return (void *) mapaddr; } weak_alias (__mmap, mmap) diff --git a/sysdeps/mach/hurd/mmap64.c b/sysdeps/mach/hurd/mmap64.c index ced469db18..282b7525c8 100644 --- a/sysdeps/mach/hurd/mmap64.c +++ b/sysdeps/mach/hurd/mmap64.c @@ -28,8 +28,8 @@ for errors (in which case `errno' is set). A successful `mmap' call deallocates any previous mapping for the affected region. */ -__ptr_t -__mmap64 (__ptr_t addr, size_t len, int prot, int flags, int fd, +void * +__mmap64 (void *addr, size_t len, int prot, int flags, int fd, __off64_t offset) { vm_offset_t small_offset = (vm_offset_t) offset; diff --git a/sysdeps/mach/mprotect.c b/sysdeps/mach/mprotect.c index 477017da39..84a72850ac 100644 --- a/sysdeps/mach/mprotect.c +++ b/sysdeps/mach/mprotect.c @@ -25,7 +25,7 @@ (and sets errno). */ int -__mprotect (__ptr_t addr, size_t len, int prot) +__mprotect (void *addr, size_t len, int prot) { kern_return_t err; vm_prot_t vmprot; diff --git a/sysdeps/mach/msync.c b/sysdeps/mach/msync.c index f84553269e..b908fed141 100644 --- a/sysdeps/mach/msync.c +++ b/sysdeps/mach/msync.c @@ -33,7 +33,7 @@ unpredictable before this is done. */ int -msync (__ptr_t addr, size_t len, int flags) +msync (void *addr, size_t len, int flags) { vm_sync_t sync_flags = 0; kern_return_t err; diff --git a/sysdeps/mach/munmap.c b/sysdeps/mach/munmap.c index b5fdaeaf1b..4a98613baf 100644 --- a/sysdeps/mach/munmap.c +++ b/sysdeps/mach/munmap.c @@ -24,7 +24,7 @@ bytes. Returns 0 if successful, -1 for errors (and sets errno). */ int -__munmap (__ptr_t addr, size_t len) +__munmap (void *addr, size_t len) { kern_return_t err; -- cgit 1.4.1