rpms/dietlibc/devel dietlibc-0.31.20080212-strlen.patch,1.2,1.3
Enrico Scholz (ensc)
fedora-extras-commits at redhat.com
Thu Feb 14 20:29:42 UTC 2008
Author: ensc
Update of /cvs/extras/rpms/dietlibc/devel
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv4408
Modified Files:
dietlibc-0.31.20080212-strlen.patch
Log Message:
further strlen fixes...
dietlibc-0.31.20080212-strlen.patch:
Index: dietlibc-0.31.20080212-strlen.patch
===================================================================
RCS file: /cvs/extras/rpms/dietlibc/devel/dietlibc-0.31.20080212-strlen.patch,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- dietlibc-0.31.20080212-strlen.patch 14 Feb 2008 19:03:48 -0000 1.2
+++ dietlibc-0.31.20080212-strlen.patch 14 Feb 2008 20:29:33 -0000 1.3
@@ -5,7 +5,7 @@
-#include "alpha/strlen.c"
diff -upN dietlibc-0.31.20080212/test/string/strlen.c.strlen dietlibc-0.31.20080212/test/string/strlen.c
--- dietlibc-0.31.20080212/test/string/strlen.c.strlen 2003-12-15 14:07:42.000000000 +0100
-+++ dietlibc-0.31.20080212/test/string/strlen.c 2008-02-14 18:32:57.000000000 +0100
++++ dietlibc-0.31.20080212/test/string/strlen.c 2008-02-14 20:01:08.000000000 +0100
@@ -1,10 +1,35 @@
#include <assert.h>
#include <string.h>
@@ -62,7 +62,7 @@
-}
diff -upN dietlibc-0.31.20080212/test/Makefile.strlen dietlibc-0.31.20080212/test/Makefile
--- dietlibc-0.31.20080212/test/Makefile.strlen 2003-12-15 14:07:42.000000000 +0100
-+++ dietlibc-0.31.20080212/test/Makefile 2008-02-14 17:26:39.000000000 +0100
++++ dietlibc-0.31.20080212/test/Makefile 2008-02-14 20:01:08.000000000 +0100
@@ -13,7 +13,7 @@ gethostbyname_r getmntent getopt getpass
glob grent hasmntopt hello iconv if_nameindex ltostr malloc-debugger md5_testharness \
memccpy memchr memcmp memcpy memrchr memusage mktime mmap_test pipe printf printftest \
@@ -74,7 +74,7 @@
test: $(TESTPROGRAMS)
diff -upN dietlibc-0.31.20080212/test/runtests.sh.strlen dietlibc-0.31.20080212/test/runtests.sh
--- dietlibc-0.31.20080212/test/runtests.sh.strlen 2003-12-15 14:07:42.000000000 +0100
-+++ dietlibc-0.31.20080212/test/runtests.sh 2008-02-14 17:26:39.000000000 +0100
++++ dietlibc-0.31.20080212/test/runtests.sh 2008-02-14 20:01:08.000000000 +0100
@@ -1,6 +1,6 @@
SUBDIRS="dirent inet stdio string stdlib time"
@@ -95,7 +95,7 @@
-#include "alpha/strlen.c"
diff -upN dietlibc-0.31.20080212/lib/strstr.c.strlen dietlibc-0.31.20080212/lib/strstr.c
--- dietlibc-0.31.20080212/lib/strstr.c.strlen 2003-08-19 21:34:18.000000000 +0200
-+++ dietlibc-0.31.20080212/lib/strstr.c 2008-02-14 17:26:39.000000000 +0100
++++ dietlibc-0.31.20080212/lib/strstr.c 2008-02-14 20:01:08.000000000 +0100
@@ -4,7 +4,7 @@
char *strstr(const char *haystack, const char *needle) {
size_t nl=strlen(needle);
@@ -107,7 +107,7 @@
for (i=hl-nl+1; __likely(i); --i) {
diff -upN dietlibc-0.31.20080212/lib/strlen.c.strlen dietlibc-0.31.20080212/lib/strlen.c
--- dietlibc-0.31.20080212/lib/strlen.c.strlen 2003-08-19 21:34:18.000000000 +0200
-+++ dietlibc-0.31.20080212/lib/strlen.c 2008-02-14 19:59:19.000000000 +0100
++++ dietlibc-0.31.20080212/lib/strlen.c 2008-02-14 21:27:31.000000000 +0100
@@ -1,6 +1,7 @@
#include <endian.h>
#include "dietfeatures.h"
@@ -116,7 +116,7 @@
#ifdef WANT_SMALL_STRING_ROUTINES
size_t strlen(const char *s) {
-@@ -10,38 +11,83 @@ size_t strlen(const char *s) {
+@@ -10,38 +11,87 @@ size_t strlen(const char *s) {
return i;
}
#else
@@ -124,13 +124,13 @@
+
+#if __WORDSIZE == 64
+typedef uint64_t word_t;
-+static word_t const magic = 0x0101010101010101ull;
+#elif __WORDSIZE == 32
+typedef uint32_t word_t;
-+static word_t const magic = 0x01010101u;
+#else
+#error unsupported __WORDSIZE
+#endif
++
++static word_t const magic = (word_t)(0x0101010101010101ull);
size_t strlen(const char *s)
{
@@ -177,37 +177,41 @@
+ word += (word << 8) + (word << 16);
+ t += word >> 26;
+ break;
++
++ default: { char exc[sizeof(word)==8]; }
+ }
#else
- if ((word & 0x80800000) == 0) {
- word <<= 16;
- t += 2;
-+ /* results into 0x8080 0000 or 0x80808080 00000000 */
-+ mask = (magic << 7) & ~((1u<<(sizeof(magic)*8/2))-1);
++ mask = (magic << 7);
+
-+ if (sizeof(word)>=8) {
++ switch (sizeof(word)) {
++ case 8:
++ mask <<= 4*8;
+ if ((word & mask) == 0) {
+ t += 4;
+ word <<= 4*8;
+ }
-+
-+ mask <<= 2*8;
-+ }
++ /* fallthrough */
+
-+ if (sizeof(word)>=4) {
++ case 4:
++ mask <<= 2*8;
+ if ((word & mask) == 0) {
+ t += 2;
+ word <<= 2*8;
+ }
-+
-+ mask <<= 1*8;
-+ }
++ /* fallthrough */
+
-+ if (sizeof(word)>=2) {
++ case 2:
++ mask <<= 1*8;
+ if ((word & mask) == 0) {
+ t += 1;
+ word <<= 1*8;
+ }
++ break;
++
++ default: { char exc[sizeof(word)==8]; }
}
- if ((word & 0x80000000) == 0) t += 1;
#endif
More information about the fedora-extras-commits
mailing list