rpms/dietlibc/devel dietlibc-0.31.20080212-strlen.patch, NONE, 1.1 dietlibc.spec, 1.37, 1.38
Enrico Scholz (ensc)
fedora-extras-commits at redhat.com
Thu Feb 14 16:31:59 UTC 2008
- Previous message (by thread): rpms/clamav/EL-4 .cvsignore, 1.6, 1.7 clamav.spec, 1.33, 1.34 sources, 1.19, 1.20
- Next message (by thread): rpms/krusader/devel krusader-1.80.0-gcc43-compile-fix.patch, NONE, 1.1 krusader.spec, 1.18, 1.19
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Author: ensc
Update of /cvs/extras/rpms/dietlibc/devel
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv31223
Modified Files:
dietlibc.spec
Added Files:
dietlibc-0.31.20080212-strlen.patch
Log Message:
added strlen patch; build testsuite with -fno-builtin
dietlibc-0.31.20080212-strlen.patch:
--- NEW FILE dietlibc-0.31.20080212-strlen.patch ---
diff -upN dietlibc-0.31.20080212/x86_64/strlen.c.strlen dietlibc-0.31.20080212/x86_64/strlen.c
--- dietlibc-0.31.20080212/x86_64/strlen.c.strlen 2007-10-04 18:19:15.000000000 +0200
+++ dietlibc-0.31.20080212/x86_64/strlen.c 1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-#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 17:23:25.000000000 +0100
@@ -2,9 +2,24 @@
#include <string.h>
int main() {
- const char* x="foo bar baz";
+ /* make it large enough to test all possible alignments, number of trailing
+ * bytes and word sizes */
+ char x[33]= { [0] = '\0' };
+
+ size_t i, j, k;
assert(strlen("")==0);
- assert(strlen(x)==11);
- assert(strlen(x+5)==6);
+
+ /* run it twice; during first run, all trailing bytes are \0. In second run,
+ * they are initialized to non \0 */
+ for (k=0; k<2; ++k) {
+ for (j=0; j<32; ++j) {
+ x[j] = j%10 + '0';
+ x[j+1] = '\0';
+
+ for (i=0; i<=j; ++i)
+ assert(strlen(x+i)==j+1-i);
+ }
+ }
+
return 0;
}
diff -upN dietlibc-0.31.20080212/test/strlen.c.strlen dietlibc-0.31.20080212/test/strlen.c
--- dietlibc-0.31.20080212/test/strlen.c.strlen 2007-11-17 15:29:53.000000000 +0100
+++ dietlibc-0.31.20080212/test/strlen.c 1970-01-01 01:00:00.000000000 +0100
@@ -1,11 +0,0 @@
-#include <assert.h>
-#include <string.h>
-
-int main() {
- const char* x="foo bar baz";
- size_t i;
- assert(strlen("")==0);
- for (i=0; i<11; ++i)
- assert(strlen(x+i)==11-i);
- return 0;
-}
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:24:12.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 \
protoent prototypes putenv pwent rand48 read1 readdir regex select sendfile servent siglist \
-speed spent sprintf sscanf stdarg strcasecmp strcmp strlen strncat strncpy strptime strrchr \
+speed spent sprintf sscanf stdarg strcasecmp strcmp strncat strncpy strptime strrchr \
strstr strtol sysenter ungetc waitpid
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:24:01.000000000 +0100
@@ -1,6 +1,6 @@
SUBDIRS="dirent inet stdio string stdlib time"
-TESTPROGRAMS="adjtime argv atexit bsearch byteswap calloc confstr empty flush fputc ffs fnmatch ftw fwrite getaddrinfo getenv getdelim getgrnam gethostbyaddr gethostbyname gethostbyname_r getmntent getopt getpwnam getservbyname getservbyport getusershell glob grent hasmntopt hello iconv if_nameindex ltostr malloc-debugger md5_testharness memccpy memchr memcmp memcpy memrchr memusage mktime mmap_test pipe printf printftest protoent prototypes putenv pwent rand48 readdir regex select sendfile servent siglist speed spent sprintf sscanf stdarg strcasecmp strcmp strlen strncat strncpy strptime strrchr strstr strtol sysenter ungetc waitpid"
+TESTPROGRAMS="adjtime argv atexit bsearch byteswap calloc confstr empty flush fputc ffs fnmatch ftw fwrite getaddrinfo getenv getdelim getgrnam gethostbyaddr gethostbyname gethostbyname_r getmntent getopt getpwnam getservbyname getservbyport getusershell glob grent hasmntopt hello iconv if_nameindex ltostr malloc-debugger md5_testharness memccpy memchr memcmp memcpy memrchr memusage mktime mmap_test pipe printf printftest protoent prototypes putenv pwent rand48 readdir regex select sendfile servent siglist speed spent sprintf sscanf stdarg strcasecmp strcmp strncat strncpy strptime strrchr strstr strtol sysenter ungetc waitpid"
STDIN="read1"
PASS="getpass"
diff -upN dietlibc-0.31.20080212/sparc64/strlen.c.strlen dietlibc-0.31.20080212/sparc64/strlen.c
--- dietlibc-0.31.20080212/sparc64/strlen.c.strlen 2007-10-04 18:19:15.000000000 +0200
+++ dietlibc-0.31.20080212/sparc64/strlen.c 1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-#include "alpha/strlen.c"
diff -upN dietlibc-0.31.20080212/ppc64/strlen.c.strlen dietlibc-0.31.20080212/ppc64/strlen.c
--- dietlibc-0.31.20080212/ppc64/strlen.c.strlen 2007-10-04 18:19:15.000000000 +0200
+++ dietlibc-0.31.20080212/ppc64/strlen.c 1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-#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 16:40:23.000000000 +0100
@@ -4,7 +4,7 @@
char *strstr(const char *haystack, const char *needle) {
size_t nl=strlen(needle);
size_t hl=strlen(haystack);
- int i;
+ size_t i;
if (!nl) goto found;
if (nl>hl) return 0;
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 17:06:39.000000000 +0100
@@ -1,6 +1,7 @@
#include <endian.h>
#include "dietfeatures.h"
#include <string.h>
+#include <stdint.h>
#ifdef WANT_SMALL_STRING_ROUTINES
size_t strlen(const char *s) {
@@ -10,38 +11,64 @@ size_t strlen(const char *s) {
return i;
}
#else
-static const unsigned long magic = 0x01010101;
+
+#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
size_t strlen(const char *s)
{
const char *t = s;
- unsigned long word;
+ word_t word;
if (!s) return 0;
/* Byte compare up until word boundary */
- for (; ((unsigned long) t & 3); t++)
+ for (; ((unsigned long) t & (sizeof(magic)-1)); t++)
if (!*t) return t - s;
/* Word compare */
do {
- word = *((unsigned long *) t); t += 4;
+ word = *((word_t const *) t); t += sizeof word;
word = (word - magic) &~ word;
word &= (magic << 7);
} while (__likely(word == 0));
-#if BYTE_ORDER == LITTLE_ENDIAN
- /* word & 0x80808080 == word */
- word = (word - 1) & (magic << 10);
- word += (word << 8) + (word << 16);
- t += word >> 26;
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+
+ if (sizeof(word)==8) {
+ /* word & 0x8080808080808080 == word */
+ word = (word - 1) & (magic << 8);
+ word += (word << 32);
+ word += (word << 16);
+ word += (word << 8);
+ t += word >> 56;
+ } else if (sizeof(word)==4) {
+ /* word & 0x80808080 == word */
+ word = (word - 1) & (magic << 10);
+ word += (word << 8) + (word << 16);
+ t += word >> 26;
+ }
+
#else
- if ((word & 0x80800000) == 0) {
- word <<= 16;
+
+ if (sizeof(word)>=8 && (word & 0x8080808000000000ull) == 0)
+ t += 4;
+
+ if (sizeof(word)>=4 && (word & 0x80800000u) == 0)
t += 2;
- }
- if ((word & 0x80000000) == 0) t += 1;
-#endif
- return ((const char *) t) - 4 - s;
+
+ if (sizeof(word)>=2 && (word & 0x8000u) == 0)
+ t += 1;
+
+#endif /* __BYTE_ORDER */
+
+ return t - sizeof(word) - s;
}
-#endif
+#endif /* WANT_SMALL_STRING_ROUTINES */
diff -upN dietlibc-0.31.20080212/ia64/strlen.c.strlen dietlibc-0.31.20080212/ia64/strlen.c
--- dietlibc-0.31.20080212/ia64/strlen.c.strlen 2007-10-04 18:19:15.000000000 +0200
+++ dietlibc-0.31.20080212/ia64/strlen.c 1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-#include "alpha/strlen.c"
diff -upN dietlibc-0.31.20080212/alpha/strlen.c.strlen dietlibc-0.31.20080212/alpha/strlen.c
--- dietlibc-0.31.20080212/alpha/strlen.c.strlen 2001-01-09 18:57:38.000000000 +0100
+++ dietlibc-0.31.20080212/alpha/strlen.c 1970-01-01 01:00:00.000000000 +0100
@@ -1,32 +0,0 @@
-#include <string.h>
-
-static const unsigned long long magic = 0x0101010101010101LL;
-
-size_t strlen(const char *s)
-{
- const char *t = s;
- unsigned long long word;
-
- if (!s) return 0;
-
- /* Byte compare up until 64 bit word boundary */
- for (; ((unsigned long long) t & 7); t++)
- if (!*t) return t - s;
-
- /* Word compare */
- do {
- word = *((unsigned long long *) t); t += 8;
- word = (word - magic) &~ word;
- word &= (magic << 7);
- } while (word == 0);
-
- /* word & 0x8080808080808080 == word */
- word = (word - 1) & (magic << 8);
- word += (word << 32);
- word += (word << 16);
- word += (word << 8);
- t += word >> 56;
- return ((const char *) t) - 8 - s;
-}
-
-
Index: dietlibc.spec
===================================================================
RCS file: /cvs/extras/rpms/dietlibc/devel/dietlibc.spec,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -r1.37 -r1.38
--- dietlibc.spec 14 Feb 2008 12:10:24 -0000 1.37
+++ dietlibc.spec 14 Feb 2008 16:31:20 -0000 1.38
@@ -51,6 +51,7 @@
Patch34: dietlibc-0.31.20080212-printffmt.patch
Patch40: dietlibc-0.31-printftest.patch
Patch41: dietlibc-0.31.20080212-teststdout.patch
+Patch42: dietlibc-0.31.20080212-strlen.patch
BuildRoot: %_tmppath/%name-%version-%release-buildroot
%{?with_dynamic:Requires: dietlibc-lib = %version-%release}
%{!?with_dynamic:Obsoletes: dietlibc-lib < %version-%release}
@@ -91,6 +92,8 @@
%patch40 -p1 -b .printftest
%patch41 -p1 -b .teststdout
+%patch42 -p1 -b .strlen
+
%if %{without ssp}
%patch20 -p1 -b .nostackprotector
@@ -104,7 +107,7 @@
sed -i -e 's!strip !: !g' Makefile
%global fixcflags -fomit-frame-pointer -fno-exceptions -fno-asynchronous-unwind-tables %xtra_fixcflags -Os -g3
-%global basemakeflags prefix=%_libdir/dietlibc BINDIR=%_bindir MAN1DIR=%_mandir/man1 COMMENT=: CFLAGS="$RPM_OPT_FLAGS %fixcflags" PDIET=%_libdir/dietlibc
+%global basemakeflags prefix=%_libdir/dietlibc BINDIR=%_bindir MAN1DIR=%_mandir/man1 COMMENT=: CFLAGS="$RPM_OPT_FLAGS %fixcflags $XTRA_CFLAGS" PDIET=%_libdir/dietlibc
%global makeflags %basemakeflags
for i in `find test -name 'runtests.sh'`; do
@@ -147,7 +150,7 @@
info locals
quit
EOF
-gdb --batch -x /tmp/gdb.cmd $objdir/diet
+gdb --batch -x /tmp/gdb.cmd $objdir/diet < /dev/null
set -e
@@ -170,6 +173,7 @@
%check
+XTRA_CFLAGS='-fno-builtin'
make %makeflags -C test all %{?_smp_mflags} DIET=$(echo `pwd`/bin-*/diet) -k || :
make %makeflags -C test/inet all %{?_smp_mflags} DIET=$(echo `pwd`/bin-*/diet) || :
- Previous message (by thread): rpms/clamav/EL-4 .cvsignore, 1.6, 1.7 clamav.spec, 1.33, 1.34 sources, 1.19, 1.20
- Next message (by thread): rpms/krusader/devel krusader-1.80.0-gcc43-compile-fix.patch, NONE, 1.1 krusader.spec, 1.18, 1.19
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the fedora-extras-commits
mailing list