This is the mail archive of the glibc-cvs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

GNU C Library master sources branch master updated. glibc-2.18-488-gd674f0e


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, master has been updated
       via  d674f0ef3898c0d1fd5cec76c1c736d9cd9bc7d1 (commit)
      from  6905a19f7a8443950f105b6716f6b4b1f98c4dbd (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=d674f0ef3898c0d1fd5cec76c1c736d9cd9bc7d1

commit d674f0ef3898c0d1fd5cec76c1c736d9cd9bc7d1
Author: OndÅ?ej Bílka <neleai@seznam.cz>
Date:   Wed Dec 4 02:02:25 2013 +0100

    Refactor several debug routines.
    
    To simplify additions of debug routines we replace a custom function
    implementation by a simple call.

diff --git a/ChangeLog b/ChangeLog
index de64f3f..6320d19 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2013-12-04  OndÅ?ej Bílka  <neleai@seznam.cz>
+
+	* debug/memcpy_chk.c (__memcpy_chk): Use call instead of custom
+	implementation.
+	* debug/memmove_chk.c (MEMMOVE_CHK): Likewise.
+	* debug/mempcpy_chk.c (__mempcpy_chk): Likewise.
+	* debug/memset_chk.c (__memset_chk): Likewise.
+	* debug/stpncpy_chk.c (__stpncpy_chk): Likewise.
+	* debug/strncpy_chk.c: Likewise.
+
 2013-12-03  Joseph Myers  <joseph@codesourcery.com>
 
 	[BZ #15268]
diff --git a/debug/memcpy_chk.c b/debug/memcpy_chk.c
index a53dd76..5bbc44f 100644
--- a/debug/memcpy_chk.c
+++ b/debug/memcpy_chk.c
@@ -32,34 +32,5 @@ __memcpy_chk (dstpp, srcpp, len, dstlen)
   if (__builtin_expect (dstlen < len, 0))
     __chk_fail ();
 
-  unsigned long int dstp = (long int) dstpp;
-  unsigned long int srcp = (long int) srcpp;
-
-  /* Copy from the beginning to the end.  */
-
-  /* If there not too few bytes to copy, use word copy.  */
-  if (len >= OP_T_THRES)
-    {
-      /* Copy just a few bytes to make DSTP aligned.  */
-      len -= (-dstp) % OPSIZ;
-      BYTE_COPY_FWD (dstp, srcp, (-dstp) % OPSIZ);
-
-      /* Copy whole pages from SRCP to DSTP by virtual address manipulation,
-	 as much as possible.  */
-
-      PAGE_COPY_FWD_MAYBE (dstp, srcp, len, len);
-
-      /* Copy from SRCP to DSTP taking advantage of the known alignment of
-	 DSTP.  Number of bytes remaining is put in the third argument,
-	 i.e. in LEN.  This number may vary from machine to machine.  */
-
-      WORD_COPY_FWD (dstp, srcp, len, len);
-
-      /* Fall out and copy the tail.  */
-    }
-
-  /* There are just a few bytes to copy.  Use byte memory operations.  */
-  BYTE_COPY_FWD (dstp, srcp, len);
-
-  return dstpp;
+  return memcpy (dstpp, srcpp, len);
 }
diff --git a/debug/memmove_chk.c b/debug/memmove_chk.c
index 3ea34c6..6337e76 100644
--- a/debug/memmove_chk.c
+++ b/debug/memmove_chk.c
@@ -36,66 +36,5 @@ MEMMOVE_CHK (dest, src, len, destlen)
   if (__builtin_expect (destlen < len, 0))
     __chk_fail ();
 
-  unsigned long int dstp = (long int) dest;
-  unsigned long int srcp = (long int) src;
-
-  /* This test makes the forward copying code be used whenever possible.
-     Reduces the working set.  */
-  if (dstp - srcp >= len)	/* *Unsigned* compare!  */
-    {
-      /* Copy from the beginning to the end.  */
-
-      /* If there not too few bytes to copy, use word copy.  */
-      if (len >= OP_T_THRES)
-	{
-	  /* Copy just a few bytes to make DSTP aligned.  */
-	  len -= (-dstp) % OPSIZ;
-	  BYTE_COPY_FWD (dstp, srcp, (-dstp) % OPSIZ);
-
-	  /* Copy whole pages from SRCP to DSTP by virtual address
-	     manipulation, as much as possible.  */
-
-	  PAGE_COPY_FWD_MAYBE (dstp, srcp, len, len);
-
-	  /* Copy from SRCP to DSTP taking advantage of the known
-	     alignment of DSTP.  Number of bytes remaining is put
-	     in the third argument, i.e. in LEN.  This number may
-	     vary from machine to machine.  */
-
-	  WORD_COPY_FWD (dstp, srcp, len, len);
-
-	  /* Fall out and copy the tail.  */
-	}
-
-      /* There are just a few bytes to copy.  Use byte memory operations.  */
-      BYTE_COPY_FWD (dstp, srcp, len);
-    }
-  else
-    {
-      /* Copy from the end to the beginning.  */
-      srcp += len;
-      dstp += len;
-
-      /* If there not too few bytes to copy, use word copy.  */
-      if (len >= OP_T_THRES)
-	{
-	  /* Copy just a few bytes to make DSTP aligned.  */
-	  len -= dstp % OPSIZ;
-	  BYTE_COPY_BWD (dstp, srcp, dstp % OPSIZ);
-
-	  /* Copy from SRCP to DSTP taking advantage of the known
-	     alignment of DSTP.  Number of bytes remaining is put
-	     in the third argument, i.e. in LEN.  This number may
-	     vary from machine to machine.  */
-
-	  WORD_COPY_BWD (dstp, srcp, len, len);
-
-	  /* Fall out and copy the tail.  */
-	}
-
-      /* There are just a few bytes to copy.  Use byte memory operations.  */
-      BYTE_COPY_BWD (dstp, srcp, len);
-    }
-
-  return dest;
+  return memmove (dest, src, len);
 }
diff --git a/debug/mempcpy_chk.c b/debug/mempcpy_chk.c
index 6895883..1573a29 100644
--- a/debug/mempcpy_chk.c
+++ b/debug/mempcpy_chk.c
@@ -33,34 +33,5 @@ __mempcpy_chk (dstpp, srcpp, len, dstlen)
   if (__builtin_expect (dstlen < len, 0))
     __chk_fail ();
 
-  unsigned long int dstp = (long int) dstpp;
-  unsigned long int srcp = (long int) srcpp;
-
-  /* Copy from the beginning to the end.  */
-
-  /* If there not too few bytes to copy, use word copy.  */
-  if (len >= OP_T_THRES)
-    {
-      /* Copy just a few bytes to make DSTP aligned.  */
-      len -= (-dstp) % OPSIZ;
-      BYTE_COPY_FWD (dstp, srcp, (-dstp) % OPSIZ);
-
-      /* Copy whole pages from SRCP to DSTP by virtual address manipulation,
-	 as much as possible.  */
-
-      PAGE_COPY_FWD_MAYBE (dstp, srcp, len, len);
-
-      /* Copy from SRCP to DSTP taking advantage of the known alignment of
-	 DSTP.  Number of bytes remaining is put in the third argument,
-	 i.e. in LEN.  This number may vary from machine to machine.  */
-
-      WORD_COPY_FWD (dstp, srcp, len, len);
-
-      /* Fall out and copy the tail.  */
-    }
-
-  /* There are just a few bytes to copy.  Use byte memory operations.  */
-  BYTE_COPY_FWD (dstp, srcp, len);
-
-  return (void *) dstp;
+  return __mempcpy (dstpp, srcpp, len);
 }
diff --git a/debug/memset_chk.c b/debug/memset_chk.c
index bfbc29d..ef1cadb 100644
--- a/debug/memset_chk.c
+++ b/debug/memset_chk.c
@@ -28,64 +28,5 @@ __memset_chk (dstpp, c, len, dstlen)
   if (__builtin_expect (dstlen < len, 0))
     __chk_fail ();
 
-  long int dstp = (long int) dstpp;
-
-  if (len >= 8)
-    {
-      size_t xlen;
-      op_t cccc;
-
-      cccc = (unsigned char) c;
-      cccc |= cccc << 8;
-      cccc |= cccc << 16;
-      if (OPSIZ > 4)
-	/* Do the shift in two steps to avoid warning if long has 32 bits.  */
-	cccc |= (cccc << 16) << 16;
-
-      /* There are at least some bytes to set.
-	 No need to test for LEN == 0 in this alignment loop.  */
-      while (dstp % OPSIZ != 0)
-	{
-	  ((byte *) dstp)[0] = c;
-	  dstp += 1;
-	  len -= 1;
-	}
-
-      /* Write 8 `op_t' per iteration until less than 8 `op_t' remain.  */
-      xlen = len / (OPSIZ * 8);
-      while (xlen > 0)
-	{
-	  ((op_t *) dstp)[0] = cccc;
-	  ((op_t *) dstp)[1] = cccc;
-	  ((op_t *) dstp)[2] = cccc;
-	  ((op_t *) dstp)[3] = cccc;
-	  ((op_t *) dstp)[4] = cccc;
-	  ((op_t *) dstp)[5] = cccc;
-	  ((op_t *) dstp)[6] = cccc;
-	  ((op_t *) dstp)[7] = cccc;
-	  dstp += 8 * OPSIZ;
-	  xlen -= 1;
-	}
-      len %= OPSIZ * 8;
-
-      /* Write 1 `op_t' per iteration until less than OPSIZ bytes remain.  */
-      xlen = len / OPSIZ;
-      while (xlen > 0)
-	{
-	  ((op_t *) dstp)[0] = cccc;
-	  dstp += OPSIZ;
-	  xlen -= 1;
-	}
-      len %= OPSIZ;
-    }
-
-  /* Write the last few bytes.  */
-  while (len > 0)
-    {
-      ((byte *) dstp)[0] = c;
-      dstp += 1;
-      len -= 1;
-    }
-
-  return dstpp;
+  return memset (dstpp, c, len);
 }
diff --git a/debug/stpncpy_chk.c b/debug/stpncpy_chk.c
index 35a2c23..f9fa66c 100644
--- a/debug/stpncpy_chk.c
+++ b/debug/stpncpy_chk.c
@@ -31,54 +31,5 @@ __stpncpy_chk (char *dest, const char *src, size_t n, size_t destlen)
   if (__builtin_expect (destlen < n, 0))
     __chk_fail ();
 
-  if (n >= 4)
-    {
-      size_t n4 = n >> 2;
-
-      for (;;)
-	{
-	  c = *src++;
-	  *dest++ = c;
-	  if (c == '\0')
-	    break;
-	  c = *src++;
-	  *dest++ = c;
-	  if (c == '\0')
-	    break;
-	  c = *src++;
-	  *dest++ = c;
-	  if (c == '\0')
-	    break;
-	  c = *src++;
-	  *dest++ = c;
-	  if (c == '\0')
-	    break;
-	  if (--n4 == 0)
-	    goto last_chars;
-	}
-      n -= dest - s;
-      goto zero_fill;
-    }
-
- last_chars:
-  n &= 3;
-  if (n == 0)
-    return dest;
-
-  for (;;)
-    {
-      c = *src++;
-      --n;
-      *dest++ = c;
-      if (c == '\0')
-	break;
-      if (n == 0)
-	return dest;
-    }
-
- zero_fill:
-  while (n-- > 0)
-    dest[n] = '\0';
-
-  return dest - 1;
+  return __stpncpy (dest, src, n);
 }
diff --git a/debug/strncpy_chk.c b/debug/strncpy_chk.c
index d067bd9..2e078b1 100644
--- a/debug/strncpy_chk.c
+++ b/debug/strncpy_chk.c
@@ -26,63 +26,8 @@ __strncpy_chk (s1, s2, n, s1len)
      size_t n;
      size_t s1len;
 {
-  char c;
-  char *s = s1;
-
   if (__builtin_expect (s1len < n, 0))
     __chk_fail ();
 
-  --s1;
-
-  if (n >= 4)
-    {
-      size_t n4 = n >> 2;
-
-      for (;;)
-	{
-	  c = *s2++;
-	  *++s1 = c;
-	  if (c == '\0')
-	    break;
-	  c = *s2++;
-	  *++s1 = c;
-	  if (c == '\0')
-	    break;
-	  c = *s2++;
-	  *++s1 = c;
-	  if (c == '\0')
-	    break;
-	  c = *s2++;
-	  *++s1 = c;
-	  if (c == '\0')
-	    break;
-	  if (--n4 == 0)
-	    goto last_chars;
-	}
-      n = n - (s1 - s) - 1;
-      if (n == 0)
-	return s;
-      goto zero_fill;
-    }
-
- last_chars:
-  n &= 3;
-  if (n == 0)
-    return s;
-
-  do
-    {
-      c = *s2++;
-      *++s1 = c;
-      if (--n == 0)
-	return s;
-    }
-  while (c != '\0');
-
- zero_fill:
-  do
-    *++s1 = '\0';
-  while (--n > 0);
-
-  return s;
+  return strncpy (s1, s2, n);
 }

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog           |   10 ++++++++
 debug/memcpy_chk.c  |   31 +------------------------
 debug/memmove_chk.c |   63 +--------------------------------------------------
 debug/mempcpy_chk.c |   31 +------------------------
 debug/memset_chk.c  |   61 +------------------------------------------------
 debug/stpncpy_chk.c |   51 +----------------------------------------
 debug/strncpy_chk.c |   57 +---------------------------------------------
 7 files changed, 16 insertions(+), 288 deletions(-)


hooks/post-receive
-- 
GNU C Library master sources


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]