svn commit: branches/uClibc-nptl: include test/string

sjhill at uclibc.org sjhill at uclibc.org
Thu Sep 1 02:03:17 UTC 2005


Author: sjhill
Date: 2005-08-31 19:03:13 -0700 (Wed, 31 Aug 2005)
New Revision: 11303

Log:
Sync with trunk.


Modified:
   branches/uClibc-nptl/include/malloc.h
   branches/uClibc-nptl/test/string/string.c


Changeset:
Modified: branches/uClibc-nptl/include/malloc.h
===================================================================
--- branches/uClibc-nptl/include/malloc.h	2005-09-01 01:34:05 UTC (rev 11302)
+++ branches/uClibc-nptl/include/malloc.h	2005-09-01 02:03:13 UTC (rev 11303)
@@ -174,6 +174,7 @@
 #define M_MMAP_THRESHOLD    -3
 #define M_MMAP_MAX          -4
 #define M_CHECK_ACTION      -5
+#define M_PERTURB           -6
 
 /* General SVID/XPG interface to tunable parameters. */
 extern int mallopt __MALLOC_P ((int __param, int __val));
@@ -182,7 +183,7 @@
 
 
 #ifdef __cplusplus
-}; /* end of extern "C" */
+} /* end of extern "C" */
 #endif
 
 #endif /* malloc.h */

Modified: branches/uClibc-nptl/test/string/string.c
===================================================================
--- branches/uClibc-nptl/test/string/string.c	2005-09-01 01:34:05 UTC (rev 11302)
+++ branches/uClibc-nptl/test/string/string.c	2005-09-01 02:03:13 UTC (rev 11303)
@@ -337,6 +337,9 @@
 
   (void) strncat (one, "gh", 2);
   equal (one, "abcdgh", 12);		/* Count and length equal. */
+
+  (void) strncat (one, "ij", (size_t)-1);	/* set sign bit in count */
+  equal (one, "abcdghij", 13);
 }
 
 static void
@@ -357,6 +360,8 @@
   check (strncmp ("abce", "abc", 3) == 0, 11);	/* Count == length. */
   check (strncmp ("abcd", "abce", 4) < 0, 12);	/* Nudging limit. */
   check (strncmp ("abc", "def", 0) == 0, 13);	/* Zero count. */
+  check (strncmp ("abc", "", (size_t)-1) > 0, 14); /* set sign bit in count */
+  check (strncmp ("abc", "abc", (size_t)-2) == 0, 15);
 }
 
 static void
@@ -423,6 +428,29 @@
 }
 
 static void
+test_strnlen (void)
+{
+  it = "strnlen";
+  check (strnlen ("", 10) == 0, 1);		/* Empty. */
+  check (strnlen ("a", 10) == 1, 2);		/* Single char. */
+  check (strnlen ("abcd", 10) == 4, 3);	/* Multiple chars. */
+  check (strnlen ("foo", (size_t)-1) == 3, 4);	/* limits of n. */
+
+  {
+    char buf[4096];
+    int i;
+    char *p;
+    for (i=0; i < 0x100; i++)
+      {
+	p = (char *) ((unsigned long int)(buf + 0xff) & ~0xff) + i;
+	strcpy (p, "OK");
+	strcpy (p+3, "BAD/WRONG");
+	check (strnlen (p, 100) == 2, 5+i);
+      }
+   }
+}
+
+static void
 test_strchr (void)
 {
   it = "strchr";
@@ -1329,6 +1357,9 @@
   /* strlen.  */
   test_strlen ();
 
+  /* strnlen.  */
+  test_strnlen ();
+
   /* strchr.  */
   test_strchr ();
 



More information about the uClibc-cvs mailing list