about summary refs log tree commit diff
path: root/string/memrchr.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 /string/memrchr.c
parent0df595b23a829c9169ec418a19eef9006b4ae801 (diff)
downloadglibc-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 'string/memrchr.c')
-rw-r--r--string/memrchr.c27
1 files changed, 12 insertions, 15 deletions
diff --git a/string/memrchr.c b/string/memrchr.c
index 0ecfe08842..f9e49a4b7f 100644
--- a/string/memrchr.c
+++ b/string/memrchr.c
@@ -27,9 +27,6 @@
 # include <config.h>
 #endif
 
-#undef __ptr_t
-#define __ptr_t void *
-
 #if defined _LIBC
 # include <string.h>
 # include <memcopy.h>
@@ -55,13 +52,13 @@
 #endif
 
 /* Search no more than N bytes of S for C.  */
-__ptr_t
+void *
 #ifndef MEMRCHR
 __memrchr
 #else
 MEMRCHR
 #endif
-     (const __ptr_t s, int c_in, size_t n)
+     (const void *s, int c_in, size_t n)
 {
   const unsigned char *char_ptr;
   const unsigned long int *longword_ptr;
@@ -77,7 +74,7 @@ MEMRCHR
 		 & (sizeof (longword) - 1)) != 0;
        --n)
     if (*--char_ptr == c)
-      return (__ptr_t) char_ptr;
+      return (void *) char_ptr;
 
   /* All these elucidatory comments refer to 4-byte longwords,
      but the theory applies equally well to 8-byte longwords.  */
@@ -162,22 +159,22 @@ MEMRCHR
 
 #if LONG_MAX > 2147483647
 	  if (cp[7] == c)
-	    return (__ptr_t) &cp[7];
+	    return (void *) &cp[7];
 	  if (cp[6] == c)
-	    return (__ptr_t) &cp[6];
+	    return (void *) &cp[6];
 	  if (cp[5] == c)
-	    return (__ptr_t) &cp[5];
+	    return (void *) &cp[5];
 	  if (cp[4] == c)
-	    return (__ptr_t) &cp[4];
+	    return (void *) &cp[4];
 #endif
 	  if (cp[3] == c)
-	    return (__ptr_t) &cp[3];
+	    return (void *) &cp[3];
 	  if (cp[2] == c)
-	    return (__ptr_t) &cp[2];
+	    return (void *) &cp[2];
 	  if (cp[1] == c)
-	    return (__ptr_t) &cp[1];
+	    return (void *) &cp[1];
 	  if (cp[0] == c)
-	    return (__ptr_t) cp;
+	    return (void *) cp;
 	}
 
       n -= sizeof (longword);
@@ -188,7 +185,7 @@ MEMRCHR
   while (n-- > 0)
     {
       if (*--char_ptr == c)
-	return (__ptr_t) char_ptr;
+	return (void *) char_ptr;
     }
 
   return 0;