diff --git a/.gitignore b/.gitignore index acde95c..7f1ea53 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ dietlibc-0.32.tar.bz2 dietlibc-0.32.tar.bz2.sig /dietlibc-0.33.20101223.tar.bz2 +/dietlibc-0.33.20110311.tar.bz2 diff --git a/dietlibc-github.patch b/dietlibc-github.patch index e31f22f..84a5b44 100644 --- a/dietlibc-github.patch +++ b/dietlibc-github.patch @@ -1,3 +1,112 @@ + .gitignore | 1 + + Makefile | 76 +++++++++++++---------- + alpha/start.S | 9 +++ + arm/__aeabi_unwind_cpp.S | 25 +++----- + arm/__fadvise.c | 5 +- + arm/__guard.S | 3 + + arm/__longjmp.S | 13 +++-- + arm/__testandset.S | 16 ++++- + arm/arm-features.h | 103 ++++++++++++++++++++++++++++++++ + arm/clone.S | 22 ++++---- + arm/dyn_syscalls.S | 18 ++++-- + arm/mcount.S | 10 +-- + arm/md5asm.S | 26 +++----- + arm/mmap.S | 42 ------------- + arm/setjmp.S | 29 +++++---- + arm/start.S | 65 +++++++++++++-------- + arm/strcpy.S | 12 +--- + arm/strlen.S | 15 +---- + arm/syscalls.h | 65 ++++---------------- + arm/unified.S | 45 +++++++++----- + arm/waitpid.S | 19 ++---- + dietdirent.h | 6 ++- + dietelfinfo.h | 20 ++++++ + dietfeatures.h | 14 +++++ + dietpagesize.h | 31 ++++++++++ + dynlinker/ldso_start.S | 9 +++ + i386/start.S | 8 ++- + ia64/start.S | 10 +++ + include/paths.h | 2 +- + include/stdlib.h | 8 ++- + include/sys/shm.h | 9 --- + lib/__dtostr.c | 18 ++++-- + lib/__get_elf_aux_value.c | 14 +++++ + lib/__nice.c | 8 ++- + lib/__utime.c | 5 +- + lib/__v_printf.c | 59 ++++++++++--------- + lib/alloc.c | 9 ++- + lib/closedir.c | 4 +- + lib/mmap64.c | 6 +- + lib/opendir.c | 4 +- + lib/readdir.c | 2 +- + lib/readdir64.c | 6 +- + lib/stack_smash_handler2.c | 13 ++++- + lib/stackgap.c | 37 ++++++++++- + libcompat/syscall.S | 8 ++- + libcruft/getpagesize.c | 28 ++++----- + libcruft/sysconf.c | 17 ++++-- + libm/ceil.c | 92 +++++++++++++++++++++++++++++ + libm/gamma.c | 26 ++++---- + librpc/clnt_raw.c | 11 ++- + librpc/clnt_udp.c | 2 +- + libugly/strftime.c | 1 + + libugly/strptime.c | 5 +- + mips/start.S | 9 +++ + parisc/start.S | 10 +++ + ppc/start.S | 9 +++ + ppc64/start.S | 9 +++ + s390/start.S | 11 ++++ + s390x/start.S | 11 ++++ + sparc/shmat.c | 8 +-- + sparc/start.S | 11 ++++ + sparc64/start.S | 11 ++++ + syscalls.s/environ.S | 16 +++++ + syscalls.s/fadvise64.S | 9 +-- + test/.gitignore | 85 ++++++++++++++++++++++++++ + test/Makefile | 10 ++-- + test/adjtime.c | 18 +++++- + test/asprintf.c | 2 +- + test/atexit.c | 2 +- + test/bsearch.c | 2 +- + test/byteswap.c | 8 +- + test/cycles.c | 5 +- + test/dirent/.gitignore | 2 + + test/ftruncate.c | 53 +++++++++++++++++ + test/getmntent.c | 6 +-- + test/getservbyname.c | 1 + + test/if_nameindex.c | 4 + + test/malloc-debugger.c | 2 +- + test/math.c | 29 +++++++++ + test/mktime.c | 6 +- + test/mmap_test.c | 2 +- + test/pipe.c | 3 + + test/printf.c | 44 ++++++++++++-- + test/printftest.c | 6 +- + test/rand48.c | 12 ++-- + test/runtests.sh | 2 +- + test/sendfile.c | 2 +- + test/setjmp.c | 106 +++++++++++++++++++++++++++++++++ + test/sigsetjmp.c | 140 ++++++++++++++++++++++++++++++++++++++++++++ + test/speed.c | 4 +- + test/stdio/.gitignore | 14 +++++ + test/stdio/tstscanf.c | 4 +- + test/stdlib/.gitignore | 13 ++++ + test/stdlib/testsort.c | 2 + + test/stdlib/tst-calloc.c | 2 + + test/stdlib/tst-malloc.c | 6 ++- + test/stdlib/tst-strtod.c | 4 +- + test/string/.gitignore | 16 +++++ + test/sysconf.c | 80 +++++++++++++++++++++++++ + test/sysenter.c | 6 +- + test/time/.gitignore | 4 + + test/time/tst-strftime.c | 6 +- + test/time/tst-strptime.c | 23 ++++++- + test/waitpid.c | 2 +- + x86_64/__time.S | 11 ++++ + x86_64/start.S | 16 +++++ + x86_64/time.S | 12 +---- + 107 files changed, 1536 insertions(+), 466 deletions(-) + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0a72698 @@ -200,42 +309,6 @@ index 143113b..a4f0c0c 100644 +GIT_CVSIMPORT=git cvsimport +cvsimport: + $(GIT_CVSIMPORT) -k -p '--cvs-direct' -d :pserver:cvs@cvs.fefe.de:/cvs dietlibc -diff --git a/alpha/__alarm.c b/alpha/__alarm.c -deleted file mode 100644 -index 7ca35cb..0000000 ---- a/alpha/__alarm.c -+++ /dev/null -@@ -1,13 +0,0 @@ --#include --#include -- --unsigned int alarm(unsigned int seconds) { -- struct itimerval old, new; -- unsigned int ret; -- new.it_interval.tv_usec=0; -- new.it_interval.tv_sec=0; -- new.it_value.tv_usec =0; -- new.it_value.tv_sec =(long)seconds; -- if (setitimer(ITIMER_REAL,&new,&old)==-1) return 0; -- return old.it_value.tv_sec+(old.it_value.tv_usec?1:0); --} -diff --git a/alpha/__time.c b/alpha/__time.c -deleted file mode 100644 -index 07275e0..0000000 ---- a/alpha/__time.c -+++ /dev/null -@@ -1,11 +0,0 @@ --#include --#include -- --time_t time(time_t *foo) { -- struct timeval tv; -- time_t tmp=(time_t)-1; -- if (gettimeofday(&tv,0)==0) -- tmp=(time_t)tv.tv_sec; -- if (foo) *foo=tmp; -- return tmp; --} diff --git a/alpha/start.S b/alpha/start.S index 7e7cf9b..b13c9c9 100644 --- a/alpha/start.S @@ -256,26 +329,6 @@ index 7e7cf9b..b13c9c9 100644 #ifdef WANT_DYNAMIC /* in v0 ($0) is the ld.so _fini pointer */ mov $0, $19 /* mov v0(dynload) to a3 */ -diff --git a/alpha/utime.S b/alpha/utime.S -deleted file mode 100644 -index a9a8aad..0000000 ---- a/alpha/utime.S -+++ /dev/null -@@ -1,3 +0,0 @@ --#include "syscalls.h" -- --syscall(utimes,utime) -diff --git a/arm/Makefile.add b/arm/Makefile.add -index f6126ec..7aaae27 100644 ---- a/arm/Makefile.add -+++ b/arm/Makefile.add -@@ -1,5 +1,6 @@ - - LIBOBJ+=$(OBJDIR)/md5asm.o $(OBJDIR)/__aeabi_unwind_cpp.o -+LIBOBJ+=$(OBJDIR)/__fadvise.o $(OBJDIR)/arm_fadvise.o - CFLAGS+=-Os -fomit-frame-pointer -fstrict-aliasing - #ifdef __ARM_EABI__ - CFLAGS+=-mabi=aapcs-linux -mfloat-abi=soft -mno-thumb-interwork diff --git a/arm/__aeabi_unwind_cpp.S b/arm/__aeabi_unwind_cpp.S index ca631bc..9334eee 100644 --- a/arm/__aeabi_unwind_cpp.S @@ -312,28 +365,21 @@ index ca631bc..9334eee 100644 +FUNC_END __aeabi_unwind_cpp_pr1 +FUNC_END __aeabi_unwind_cpp_pr0 diff --git a/arm/__fadvise.c b/arm/__fadvise.c -new file mode 100644 -index 0000000..c6748c4 ---- /dev/null +index 0aa1246..c6748c4 100644 +--- a/arm/__fadvise.c +++ b/arm/__fadvise.c -@@ -0,0 +1,17 @@ -+#include "syscalls.h" -+ -+#ifndef __NR_fadvise64 +@@ -1,7 +1,10 @@ +-#include + #include "syscalls.h" + + #ifndef __NR_fadvise64 +#define _LINUX_SOURCE +#include +#include + -+long fadvise64_64(int fd, off64_t offset, off64_t len, int advice) -+{ -+ extern long __arm_fadvise64_64(int fd, int advice, off64_t offset, off64_t len); -+ -+ return __arm_fadvise64_64(fd, advice, offset, len); -+} -+ -+int posix_fadvise(int fd, off64_t offset, off64_t len, int advise) -+ __attribute__((__alias__("fadvise64_64"))); -+#endif + long fadvise64_64(int fd, off64_t offset, off64_t len, int advice) + { + extern long __arm_fadvise64_64(int fd, int advice, off64_t offset, off64_t len); diff --git a/arm/__guard.S b/arm/__guard.S index 7218d13..a4e53aa 100644 --- a/arm/__guard.S @@ -351,10 +397,10 @@ index 7218d13..a4e53aa 100644 +.size __guard, . - __guard +.size __stack_chk_guard, . - __stack_chk_guard diff --git a/arm/__longjmp.S b/arm/__longjmp.S -index 31307bd..5850398 100644 +index 31307bd..ba03146 100644 --- a/arm/__longjmp.S +++ b/arm/__longjmp.S -@@ -1,7 +1,6 @@ +@@ -1,11 +1,14 @@ -.text -.global __longjmp -.type __longjmp,function @@ -365,8 +411,12 @@ index 31307bd..5850398 100644 mov ip, r0 movs r0, r1 moveq r0, #1 -@@ -9,3 +8,4 @@ __longjmp: - lfm f4, 4, [ip], #48 + #ifndef __SOFTFP__ +- lfm f4, 4, [ip], #48 ++ lfm f4, 4, [ip, #10*4] ++#endif ++#ifdef __IWMMXT__ ++# warning "sigjmp will not restore iwmmxt coprocessor registers" #endif ldmia ip, {r4-r11, sp, pc} +FUNC_END __longjmp @@ -503,17 +553,6 @@ index 0000000..cf330eb +#endif /* __ASSEMBLER__ */ + +#endif /* H_DIETLIBC_ARM_FEATURES_H */ -diff --git a/arm/arm_fadvise.S b/arm/arm_fadvise.S -new file mode 100644 -index 0000000..216cdcc ---- /dev/null -+++ b/arm/arm_fadvise.S -@@ -0,0 +1,5 @@ -+#include "syscalls.h" -+ -+#ifdef __NR_arm_fadvise64_64 -+syscall(arm_fadvise64_64, __arm_fadvise64_64); -+#endif diff --git a/arm/clone.S b/arm/clone.S index 4a4b2f4..b2ef450 100644 --- a/arm/clone.S @@ -579,7 +618,7 @@ index 4a4b2f4..b2ef450 100644 #endif diff --git a/arm/dyn_syscalls.S b/arm/dyn_syscalls.S -index 895657f..c128891 100644 +index a4baf28..a8fe803 100644 --- a/arm/dyn_syscalls.S +++ b/arm/dyn_syscalls.S @@ -8,11 +8,15 @@ @@ -612,7 +651,7 @@ index 895657f..c128891 100644 /* ok now include all syscalls.s (*.S) and sysdep *.S */ #include "mmap.S" -@@ -278,9 +284,11 @@ __unified_syscall: +@@ -280,9 +286,11 @@ __unified_syscall: #include "../syscalls.s/fgetxattr.S" /* other asm-files w.o. changes ... */ @@ -782,10 +821,10 @@ index d3ea131..0000000 - -#endif diff --git a/arm/setjmp.S b/arm/setjmp.S -index 6b850d4..797d21b 100644 +index 6b850d4..e7503b2 100644 --- a/arm/setjmp.S +++ b/arm/setjmp.S -@@ -1,17 +1,18 @@ +@@ -1,17 +1,20 @@ -.text -.weak setjmp -setjmp: @@ -805,26 +844,32 @@ index 6b850d4..797d21b 100644 + +FUNC_START_WEAK sigsetjmp +FUNC_START __sigsetjmp ++ stmia r0, {r4-r11, sp, lr} #ifndef __SOFTFP__ - sfm f4, 4, [r0], #48 +- sfm f4, 4, [r0], #48 ++ sfm f4, 4, [r0, #10*4] ++#endif ++#ifdef __IWMMXT__ ++# warning "setjmp will not save iwmmxt coprocessor registers" #endif - stmia r0, {r4-r11, sp, lr} - sub r0, r0, #48 +- stmia r0, {r4-r11, sp, lr} +- sub r0, r0, #48 b __sigjmp_save - +FUNC_END __sigsetjmp +FUNC_END sigsetjmp diff --git a/arm/start.S b/arm/start.S -index ccbac48..cfb298c 100644 +index d68d49d..cfb298c 100644 --- a/arm/start.S +++ b/arm/start.S -@@ -1,30 +1,29 @@ +@@ -1,23 +1,11 @@ #include "dietfeatures.h" #include "syscalls.h" -- ++#include "arm-features.h" + - .text --#ifdef __ARM_EABI__ + #ifdef __ARM_EABI__ - .align 4 -#else - .align 2 @@ -834,19 +879,16 @@ index ccbac48..cfb298c 100644 - .weak exit - .global _exit - -+#include "arm-features.h" - - #ifdef __ARM_EABI__ - --_start: - +-#ifdef __ARM_EABI__ +- +-_start: + +FUNC_START _start mov fp, #0 @ clear the frame pointer -- ldr a1, [sp], #4 @ argc -- mov a2, sp @ argv -+ ldr a1, [sp] @ argc -+ add a2, sp, #4 @ argv - ldr ip, .L3 + ldr a1, [sp] @ argc + add a2, sp, #4 @ argv +@@ -25,6 +13,17 @@ _start: add a3, a2, a1, lsl #2 @ &argv[argc] add a3, a3, #4 @ envp str a3, [ip, #0] @ environ = envp @@ -946,7 +988,7 @@ index ccbac48..cfb298c 100644 .L3: .word environ(GOT) .L4: .word _GLOBAL_OFFSET_TABLE_-(1b+8) diff --git a/arm/strcpy.S b/arm/strcpy.S -index 20e1029..cc376d3 100644 +index 20e1029..7a86562 100644 --- a/arm/strcpy.S +++ b/arm/strcpy.S @@ -1,10 +1,7 @@ @@ -962,7 +1004,7 @@ index 20e1029..cc376d3 100644 #ifndef WANT_SMALL_STRING_ROUTINES mov ip, r0 ands r2, r1, #3 -@@ -61,6 +58,6 @@ strcpy: +@@ -61,6 +58,5 @@ strcpy: ldrneb r2, [r1], #1 #endif bne .Lloop @@ -971,7 +1013,6 @@ index 20e1029..cc376d3 100644 - .size strcpy,.Lfe1-strcpy + RET +FUNC_END strcpy -+ diff --git a/arm/strlen.S b/arm/strlen.S index 6b2b459..a6af8f0 100644 --- a/arm/strlen.S @@ -1007,10 +1048,10 @@ index 6b2b459..a6af8f0 100644 - .size strlen,.Lstrlen-strlen +FUNC_END strlen diff --git a/arm/syscalls.h b/arm/syscalls.h -index 774350a..6720496 100644 +index d092f55..21a6dcc 100644 --- a/arm/syscalls.h +++ b/arm/syscalls.h -@@ -697,9 +697,9 @@ +@@ -700,9 +700,9 @@ #define __ARGS_getpeername 0 #define __ARGS_socketpair 0 #define __ARGS_send 0 @@ -1022,7 +1063,7 @@ index 774350a..6720496 100644 #define __ARGS_shutdown 0 #define __ARGS_setsockopt 0 #define __ARGS_getsockopt 0 -@@ -768,70 +768,30 @@ +@@ -771,70 +771,30 @@ #ifdef __ASSEMBLER__ @@ -1103,7 +1144,7 @@ index 774350a..6720496 100644 .ifgt \typ mov ip, sp stmfd sp!,{r4, r5, r6} -@@ -843,6 +803,7 @@ +@@ -846,6 +806,7 @@ .else b __unified_syscall .endif @@ -1112,7 +1153,7 @@ index 774350a..6720496 100644 #endif diff --git a/arm/unified.S b/arm/unified.S -index 3023032..999d4f3 100644 +index e6ea3f6..bd5b987 100644 --- a/arm/unified.S +++ b/arm/unified.S @@ -1,21 +1,28 @@ @@ -1156,15 +1197,16 @@ index 3023032..999d4f3 100644 cmn r0, #4096 rsbcs r2, r0, #0 ldrcs r3, 1f -@@ -25,15 +32,17 @@ __unified_syscall: +@@ -25,17 +32,18 @@ __unified_syscall: .balign 4 1: .word errno -- --/* here we go and "reuse" the return for weak-void functions */ +FUNC_END __unified_syscall -+ + +-/* here we go and "reuse" the return for weak-void functions */ #include "dietuglyweaks.h" + +- mov pc, lr @ return + RET #else @@ -1178,13 +1220,12 @@ index 3023032..999d4f3 100644 cmn r0, #4096 movcc pc, lr @ return value comes direct from kernel. -@@ -50,11 +59,14 @@ __unified_syscall: - +@@ -53,10 +61,13 @@ __unified_syscall: /* here we go and "reuse" the return for weak-void functions */ #include "dietuglyweaks.h" -+ RET - mov pc, lr @ return ++ RET #ifndef WANT_THREAD_SAFE + .align 2 @@ -1220,22 +1261,6 @@ index 2c3a75b..0d099a8 100644 - .size waitpid, .-waitpid +FUNC_END __libc_waitpid +FUNC_END waitpid -diff --git a/diet.c b/diet.c -index e7fd3e8..22e3696 100644 ---- a/diet.c -+++ b/diet.c -@@ -32,11 +32,7 @@ static const char* Os[] = { - "sparc","-Os","-mcpu=supersparc",0, - "sparc64","-Os","-m64","-mhard-quad-float",0, - "alpha","-Os","-fomit-frame-pointer",0, --#ifdef __ARM_EABI__ -- "arm","-Os","-fomit-frame-pointer","-mfloat-abi=soft","-meabi=4",0, --#else - "arm","-Os","-fomit-frame-pointer",0, --#endif - "mips","-Os","-fomit-frame-pointer","-mno-abicalls","-fno-pic","-G","0",0, - "mipsel","-Os","-fomit-frame-pointer","-mno-abicalls","-fno-pic","-G","0",0, - "ppc","-Os","-fomit-frame-pointer","-mpowerpc-gpopt","-mpowerpc-gfxopt",0, diff --git a/dietdirent.h b/dietdirent.h index dbd7206..3e823f8 100644 --- a/dietdirent.h @@ -1368,50 +1393,29 @@ index ca278d7..da36845 100644 fini_entry: .long 0 diff --git a/i386/start.S b/i386/start.S -index 94a4f73..9ad41ff 100644 +index 361af3d..b681d05 100644 --- a/i386/start.S +++ b/i386/start.S -@@ -25,6 +25,13 @@ _start: +@@ -20,12 +20,18 @@ _start: PIC_INIT /* non-PIC: this is an empty line */ - PUT_VAR %eax, environ, %ecx /* non-PIC: movl %eax,environ */ + PUT_VAR %esi, environ, %ecx /* non-PIC: movl %esi,environ */ -+#ifdef WANT_ELFINFO -+1: add $4, %eax /* increment envp */ -+ cmpl $0, -4(%eax) /* load envp[-1] */ -+ jne 1b /* ... until envp[-1]==NULL */ -+ PUT_VAR %eax, __elfinfo, %ecx +-#ifdef WANT_SYSENTER ++#if defined(WANT_ELFINFO) || defined(WANT_SYSENTER) + /* skip environment, scan for NULL */ + 1: + lodsl + testl %eax,%eax + jnz 1b ++# ifdef WANT_ELFINFO ++ PUT_VAR %esi, __elfinfo, %ecx ++# endif +#endif + - #ifdef PROFILING - pushl $_etext - pushl $.text -diff --git a/ia64/__alarm.c b/ia64/__alarm.c -deleted file mode 100644 -index e2c499f..0000000 ---- a/ia64/__alarm.c -+++ /dev/null -@@ -1 +0,0 @@ --#include "alpha/__alarm.c" -diff --git a/ia64/__time.c b/ia64/__time.c -deleted file mode 100644 -index 7547acb..0000000 ---- a/ia64/__time.c -+++ /dev/null -@@ -1,14 +0,0 @@ --#include --#include -- --time_t time(time_t*t) { -- struct timeval tv; -- time_t ret; -- if (gettimeofday(&tv,0)) { -- ret=(time_t)-1; -- } else { -- ret=(time_t)tv.tv_sec; -- } -- if (t) *t=ret; -- return ret; --} ++#ifdef WANT_SYSENTER + /* The ELF auxvec follows the environment, consists of key/value pairs. + We are looking for key 32, which stands for the vsyscall page */ + 1: diff --git a/ia64/start.S b/ia64/start.S index 50fd015..c917721 100644 --- a/ia64/start.S @@ -1433,29 +1437,6 @@ index 50fd015..c917721 100644 #ifdef WANT_DYNAMIC /* FIXME: dl_init parameter ??? */ br.call.sptk.few rp = _dyn_start -diff --git a/ia64/utime.S b/ia64/utime.S -deleted file mode 100644 -index a9a8aad..0000000 ---- a/ia64/utime.S -+++ /dev/null -@@ -1,3 +0,0 @@ --#include "syscalls.h" -- --syscall(utimes,utime) -diff --git a/include/fcntl.h b/include/fcntl.h -index 510826c..d085ba5 100644 ---- a/include/fcntl.h -+++ b/include/fcntl.h -@@ -673,7 +673,9 @@ int utimensat(int dirfd, const char *pathname, struct timespec* t); - #endif - - #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE - 0) >= 600 -+#include "linux/fadvise.h" - int posix_fallocate(int fd, off64_t offset, off64_t len) __THROW; -+int posix_fadvise(int fd, off64_t offset, off64_t len, int advice) __THROW; - #endif - - __END_DECLS diff --git a/include/paths.h b/include/paths.h index 553b4fa..9bf216f 100644 --- a/include/paths.h @@ -1470,7 +1451,7 @@ index 553b4fa..9bf216f 100644 #define _PATH_DEVNULL "/dev/null" diff --git a/include/stdlib.h b/include/stdlib.h -index b3b0e15..bd3fabf 100644 +index 4976f86..1dd10ff 100644 --- a/include/stdlib.h +++ b/include/stdlib.h @@ -28,8 +28,12 @@ long double strtold(const char *nptr, char **endptr) __THROW; @@ -1516,41 +1497,6 @@ index 9b2d04d..70bb17e 100644 extern int shmget(key_t key, int size, int shmflg) __THROW; extern void *shmat(int shmid, const void *shmaddr, int shmflg) __THROW; extern int shmdt (const void *shmaddr) __THROW; -diff --git a/include/utime.h b/include/utime.h -index eebc4da..ce98bff 100644 ---- a/include/utime.h -+++ b/include/utime.h -@@ -12,7 +12,7 @@ struct utimbuf { - time_t modtime; /* modification time */ - }; - --int utime(const char* filename, struct utimbuf* buf) __THROW; -+int utime(const char* filename, const struct utimbuf* buf) __THROW; - - __END_DECLS - -diff --git a/lib/__alarm.c b/lib/__alarm.c -new file mode 100644 -index 0000000..9b4bc30 ---- /dev/null -+++ b/lib/__alarm.c -@@ -0,0 +1,16 @@ -+#include -+#include -+#include -+ -+#ifndef __NR_alarm -+unsigned int alarm(unsigned int seconds) { -+ struct itimerval old, new; -+ unsigned int ret; -+ new.it_interval.tv_usec=0; -+ new.it_interval.tv_sec=0; -+ new.it_value.tv_usec =0; -+ new.it_value.tv_sec =(long)seconds; -+ if (setitimer(ITIMER_REAL,&new,&old)==-1) return 0; -+ return old.it_value.tv_sec+(old.it_value.tv_usec?1:0); -+} -+#endif diff --git a/lib/__dtostr.c b/lib/__dtostr.c index 1d082e3..bc61200 100644 --- a/lib/__dtostr.c @@ -1618,32 +1564,6 @@ index 0000000..8a2e3bc + + return NULL; +} -diff --git a/lib/__mmap.c b/lib/__mmap.c -new file mode 100644 -index 0000000..1b035c3 ---- /dev/null -+++ b/lib/__mmap.c -@@ -0,0 +1,20 @@ -+#include -+#include -+#include -+ -+#ifndef __NR_mmap -+void*__mmap2(void*start,size_t length,int prot,int flags,int fd,off_t pgoffset); -+void *mmap(void *addr, size_t length, int prot, int flags, int fd, -+ off_t offset) -+{ -+ size_t pgsz = 4096; /* TODO: fix for dynamic PAGESIZEs needed? */ -+ void *res; -+ -+ if (__unlikely(offset & (pgsz - 1))) { -+ errno = -EINVAL; -+ res = MAP_FAILED; -+ } else -+ res = __mmap2(addr, length, prot, flags, fd, offset / pgsz); -+ return res; -+} -+#endif diff --git a/lib/__nice.c b/lib/__nice.c index d751104..8e205c0 100644 --- a/lib/__nice.c @@ -1664,69 +1584,22 @@ index d751104..8e205c0 100644 + return getpriority(PRIO_PROCESS,0); } #endif -diff --git a/lib/__time.c b/lib/__time.c -new file mode 100644 -index 0000000..87a6d5d ---- /dev/null -+++ b/lib/__time.c -@@ -0,0 +1,15 @@ -+#include -+#include -+#include -+ -+#ifndef __NR_time -+time_t time(time_t *t) -+{ -+ struct timeval tv; -+ if (__unlikely(gettimeofday(&tv, NULL) < 0)) -+ tv.tv_sec = -1; -+ if (t) -+ *t = tv.tv_sec; -+ return tv.tv_sec; -+} -+#endif -diff --git a/lib/__umount.c b/lib/__umount.c -new file mode 100644 -index 0000000..24bb220 ---- /dev/null -+++ b/lib/__umount.c -@@ -0,0 +1,9 @@ -+#include -+#include "syscalls.h" -+ -+#ifndef __NR_umount -+int umount(const char *target) -+{ -+ return umount2(target, 0); -+} -+#endif diff --git a/lib/__utime.c b/lib/__utime.c -new file mode 100644 -index 0000000..0e4d0df ---- /dev/null +index e013265..0e4d0df 100644 +--- a/lib/__utime.c +++ b/lib/__utime.c -@@ -0,0 +1,21 @@ -+#include -+ -+#ifndef __NR_utime +@@ -1,7 +1,10 @@ +-#include + #include + + #ifndef __NR_utime +#define _BSD_SOURCE +#include +#include + -+int utime(const char *filename, const struct utimbuf *times) -+{ -+ if (times == NULL) -+ return utimes(filename, NULL); -+ else { -+ struct timeval tvs[2]; -+ tvs[0].tv_sec = times->actime; -+ tvs[0].tv_usec = 0; -+ tvs[1].tv_sec = times->modtime; -+ tvs[1].tv_usec = 0; -+ return utimes(filename, tvs); -+ } -+} -+#endif + int utime(const char *filename, const struct utimbuf *times) + { + if (times == NULL) diff --git a/lib/__v_printf.c b/lib/__v_printf.c index 36202f5..964c005 100644 --- a/lib/__v_printf.c @@ -1913,19 +1786,6 @@ index 2530d1a..847685e 100644 MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); if (t == MAP_FAILED) lose: -diff --git a/lib/posix_fallocate.c b/lib/posix_fallocate.c -index ef9f985..82c3e1d 100644 ---- a/lib/posix_fallocate.c -+++ b/lib/posix_fallocate.c -@@ -1,7 +1,7 @@ - #define _GNU_SOURCE - #define _XOPEN_SOURCE 600 --#include - -+#include - int posix_fallocate(int fd, off64_t offset, off64_t len) { - return fallocate(fd,0,offset,len); - } diff --git a/lib/readdir.c b/lib/readdir.c index ed885a5..d80a406 100644 --- a/lib/readdir.c @@ -1971,17 +1831,10 @@ index 924f0a8..06d073b 100644 if (errno==ENOSYS) { trygetdents64=0; diff --git a/lib/stack_smash_handler2.c b/lib/stack_smash_handler2.c -index 9e85099..b03c0d5 100644 +index 9e85099..83c0cef 100644 --- a/lib/stack_smash_handler2.c +++ b/lib/stack_smash_handler2.c -@@ -2,11 +2,20 @@ - #include - - void __stack_chk_fail(void); -+void __stack_chk_fail_local(void) __attribute__((__alias__("__stack_chk_fail"))); - - /* earlier versions of ProPolice actually gave the address and function - * name as arguments to the handler, so it could print some useful +@@ -8,5 +8,16 @@ void __stack_chk_fail(void); * diagnostics. No more. :-( */ void __stack_chk_fail(void) { __write2("smashed stack detected, program terminated.\n"); @@ -1993,11 +1846,14 @@ index 9e85099..b03c0d5 100644 + * TODO: limit this to systems which are known to have an MMU (resp. is + * dietlibc with stack-protector used on systems without an MMU?) + */ -+ while (1) -+ *(char *)0 = 0; ++ *(char volatile *)0 = 0; ++ while (1) { ++ asm(""); ++ __builtin_unreachable(); ++ } } diff --git a/lib/stackgap.c b/lib/stackgap.c -index 3ba6954..d4a505b 100644 +index 6f1f5c4..1a3af01 100644 --- a/lib/stackgap.c +++ b/lib/stackgap.c @@ -16,6 +16,7 @@ @@ -2042,7 +1898,7 @@ index 3ba6954..d4a505b 100644 if (!x || !n) return; /* a kernel this old does not support thread local storage anyway */ for (i=0; i - #include +@@ -6,6 +6,9 @@ + #define _GNU_SOURCE + #include +#include "dietelfinfo.h" +#include "dietpagesize.h" @@ -2170,7 +2026,7 @@ index 5a6259c..507de94 100644 extern int __sc_nr_cpus(); static long physpages() { -@@ -40,6 +43,14 @@ long sysconf(int name) +@@ -42,6 +45,14 @@ long sysconf(int name) return limit.rlim_cur; } case _SC_CLK_TCK: @@ -2185,7 +2041,7 @@ index 5a6259c..507de94 100644 #ifdef __alpha__ return 1024; #else -@@ -47,11 +58,7 @@ long sysconf(int name) +@@ -49,11 +60,7 @@ long sysconf(int name) #endif case _SC_PAGESIZE: @@ -2198,6 +2054,104 @@ index 5a6259c..507de94 100644 case _SC_PHYS_PAGES: return physpages(); +diff --git a/libm/ceil.c b/libm/ceil.c +new file mode 100644 +index 0000000..c126b02 +--- /dev/null ++++ b/libm/ceil.c +@@ -0,0 +1,92 @@ ++/* @(#)s_ceil.c 5.1 93/09/24 */ ++/* ++ * ==================================================== ++ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. ++ * ++ * Developed at SunPro, a Sun Microsystems, Inc. business. ++ * Permission to use, copy, modify, and distribute this ++ * software is freely granted, provided that this notice ++ * is preserved. ++ * ==================================================== ++ */ ++ ++/* ++ * ceil(x) ++ * Return x rounded toward -inf to integral value ++ * Method: ++ * Bit twiddling. ++ * Exception: ++ * Inexact flag raised if x not equal to ceil(x). ++ */ ++ ++#include ++ ++typedef union { ++ double value; ++ struct { ++ unsigned int lsw; ++ unsigned int msw; ++ } parts; ++} ieee_double_shape_type; ++ ++/* Get two 32 bit ints from a double. */ ++ ++#define EXTRACT_WORDS(ix0,ix1,d) \ ++do { \ ++ ieee_double_shape_type ew_u; \ ++ ew_u.value = (d); \ ++ (ix0) = ew_u.parts.msw; \ ++ (ix1) = ew_u.parts.lsw; \ ++} while (0) ++ ++#define INSERT_WORDS(d,ix0,ix1) \ ++do { \ ++ ieee_double_shape_type iw_u; \ ++ iw_u.parts.msw = (ix0); \ ++ iw_u.parts.lsw = (ix1); \ ++ (d) = iw_u.value; \ ++} while (0) ++ ++static const double huge = 1.0e300; ++ ++double ceil(double x) ++{ ++ int i0,i1,j0; ++ unsigned int i,j; ++ EXTRACT_WORDS(i0,i1,x); ++ j0 = ((i0>>20)&0x7ff)-0x3ff; ++ if(j0<20) { ++ if(j0<0) { /* raise inexact if x != 0 */ ++ if(huge+x>0.0) {/* return 0*sign(x) if |x|<1 */ ++ if(i0<0) {i0=0x80000000;i1=0;} ++ else if((i0|i1)!=0) { i0=0x3ff00000;i1=0;} ++ } ++ } else { ++ i = (0x000fffff)>>j0; ++ if(((i0&i)|i1)==0) return x; /* x is integral */ ++ if(huge+x>0.0) { /* raise inexact flag */ ++ if(i0>0) i0 += (0x00100000)>>j0; ++ i0 &= (~i); i1=0; ++ } ++ } ++ } else if (j0>51) { ++ if(j0==0x400) return x+x; /* inf or NaN */ ++ else return x; /* x is integral */ ++ } else { ++ i = ((unsigned int)(0xffffffff))>>(j0-20); ++ if((i1&i)==0) return x; /* x is integral */ ++ if(huge+x>0.0) { /* raise inexact flag */ ++ if(i0>0) { ++ if(j0==20) i0+=1; ++ else { ++ j = i1 + (1<<(52-j0)); ++ if(j --#include -- --time_t time(time_t *t) { -- struct timeval tv; -- if (gettimeofday(&tv, 0) == -1) -- tv.tv_sec=-1; -- if (t) *t=tv.tv_sec; -- return tv.tv_sec; --} diff --git a/s390x/start.S b/s390x/start.S index 25895a6..15ad1f9 100644 --- a/s390x/start.S @@ -2502,13 +2440,6 @@ index a7841e3..bb463c9 100644 /* When starting a binary via the dynamic linker, %g1 contains the address of the shared library termination function, which will be registered with atexit(). If we are statically linked, this will -diff --git a/sparc64/__time.c b/sparc64/__time.c -deleted file mode 100644 -index efa1e8b..0000000 ---- a/sparc64/__time.c -+++ /dev/null -@@ -1 +0,0 @@ --#include "alpha/__time.c" diff --git a/sparc64/start.S b/sparc64/start.S index a79c4e7..a884658 100644 --- a/sparc64/start.S @@ -2531,30 +2462,6 @@ index a79c4e7..a884658 100644 /* When starting a binary via the dynamic linker, %g1 contains the address of the shared library termination function, which will be registered with atexit(). If we are statically linked, this will -diff --git a/syscalls.s/__pread.S b/syscalls.s/__pread.S -index 9cf11ce..dfcbbd3 100644 ---- a/syscalls.s/__pread.S -+++ b/syscalls.s/__pread.S -@@ -1,3 +1,7 @@ - #include "syscalls.h" - -+#ifdef __NR_pread64 -+syscall_weak(pread64,pread64,__libc_pread64) -+#elif defined(__NR_pread) - syscall_weak(pread,pread64,__libc_pread64) -+#endif -diff --git a/syscalls.s/__pwrite.S b/syscalls.s/__pwrite.S -index fc826d6..0bb704d 100644 ---- a/syscalls.s/__pwrite.S -+++ b/syscalls.s/__pwrite.S -@@ -1,3 +1,7 @@ - #include "syscalls.h" - -+#ifdef __NR_pwrite64 -+syscall_weak(pwrite64,pwrite64,__libc_pwrite64) -+#elif defined(__NR_pwrite) - syscall_weak(pwrite,pwrite64,__libc_pwrite64) -+#endif diff --git a/syscalls.s/environ.S b/syscalls.s/environ.S index a4dd95e..294f2d4 100644 --- a/syscalls.s/environ.S @@ -2587,87 +2494,32 @@ index a4dd95e..294f2d4 100644 +.size __elfinfo,.-__elfinfo +#endif diff --git a/syscalls.s/fadvise64.S b/syscalls.s/fadvise64.S -index 0f96da9..fe448b1 100644 +index eab3986..fe448b1 100644 --- a/syscalls.s/fadvise64.S +++ b/syscalls.s/fadvise64.S -@@ -1,3 +1,11 @@ +@@ -1,12 +1,11 @@ #include "syscalls.h" +#ifdef __NR_fadvise64 - syscall(fadvise64,fadvise64) ++syscall(fadvise64,fadvise64) + -+#ifndef __NR_fadvise64_64 + #ifndef __NR_fadvise64_64 +.set posix_fadvise, fadvise64 -+.globl posix_fadvise -+#endif -+ -+#endif -diff --git a/syscalls.s/fadvise64_64.S b/syscalls.s/fadvise64_64.S -index 1893962..9bf66b5 100644 ---- a/syscalls.s/fadvise64_64.S -+++ b/syscalls.s/fadvise64_64.S -@@ -2,4 +2,7 @@ - - #ifdef __NR_fadvise64_64 - syscall(fadvise64_64,fadvise64_64) -+ -+.set posix_fadvise, fadvise64_64 -+.globl posix_fadvise + .globl posix_fadvise +-.type posix_fadvise,@function +-posix_fadvise: #endif -diff --git a/syscalls.s/getrlimit.S b/syscalls.s/getrlimit.S -index 1c63c01..3341add 100644 ---- a/syscalls.s/getrlimit.S -+++ b/syscalls.s/getrlimit.S -@@ -1,3 +1,11 @@ - #include "syscalls.h" -+#ifdef __NR_ugetrlimit -+ -+syscall(ugetrlimit,getrlimit) -+ -+#elif defined(__NR_getrlimit) -+ - syscall(getrlimit,getrlimit) -+ -+#endif -diff --git a/syscalls.s/mmap.S b/syscalls.s/mmap.S -index 2e57fbb..486b531 100644 ---- a/syscalls.s/mmap.S -+++ b/syscalls.s/mmap.S -@@ -1,3 +1,7 @@ - #include "syscalls.h" - -+#ifdef __NR_mmap -+ - syscall(mmap,mmap) -+ -+#endif -diff --git a/syscalls.s/umount.S b/syscalls.s/umount.S -index 4a423d9..00278be 100644 ---- a/syscalls.s/umount.S -+++ b/syscalls.s/umount.S -@@ -1,3 +1,5 @@ - #include "syscalls.h" - -+#ifdef __NR_umount - syscall(umount,umount) -+#endif -diff --git a/syscalls.s/utime.S b/syscalls.s/utime.S -index 08cd221..9878b8f 100644 ---- a/syscalls.s/utime.S -+++ b/syscalls.s/utime.S -@@ -1,3 +1,5 @@ - #include "syscalls.h" - -+#ifdef __NR_utime - syscall(utime,utime) -+#endif +-#ifdef __NR_fadvise64 +-syscall(fadvise64,fadvise64) +- + #endif diff --git a/test/.gitignore b/test/.gitignore new file mode 100644 -index 0000000..9d74220 +index 0000000..92c5678 --- /dev/null +++ b/test/.gitignore -@@ -0,0 +1,81 @@ +@@ -0,0 +1,85 @@ +/adjtime +/alarm +/argv @@ -2679,10 +2531,12 @@ index 0000000..9d74220 +/confstr +/cycles +/empty ++/fadvise +/ffs +/flush +/fnmatch +/fputc ++/ftruncate +/ftw +/fwrite +/getaddrinfo @@ -2730,7 +2584,9 @@ index 0000000..9d74220 +/select +/sendfile +/servent ++/setjmp +/siglist ++/sigsetjmp +/speed +/spent +/sprintf @@ -2750,23 +2606,24 @@ index 0000000..9d74220 +/utime +/waitpid diff --git a/test/Makefile b/test/Makefile -index eea0075..8f5b964 100644 +index 2e406f3..152cf5a 100644 --- a/test/Makefile +++ b/test/Makefile -@@ -7,14 +7,14 @@ CFLAGS=-nostdinc -Wall - +@@ -8,13 +8,13 @@ CFLAGS=-nostdinc -Wall LCOMPAT=-lcompat --TESTPROGRAMS=adjtime argv asprintf atexit bsearch byteswap calloc confstr cycles empty flush fnmatch \ -+TESTPROGRAMS=adjtime alarm argv asprintf atexit bsearch byteswap calloc confstr cycles empty fadvise flush fnmatch \ - fputc ftw fwrite getaddrinfo getenv getgrnam gethostbyaddr gethostbyname \ + TESTPROGRAMS=adjtime alarm argv asprintf atexit bsearch byteswap calloc confstr cycles empty fadvise flush fnmatch \ +-fputc ftw fwrite getaddrinfo getenv getgrnam gethostbyaddr gethostbyname \ ++fputc ftruncate ftw fwrite getaddrinfo getenv getgrnam gethostbyaddr gethostbyname \ gethostbyname_r getmntent getopt getpass getpwnam getservbyname getservbyport getusershell \ -glob grent hasmntopt hello iconv if_nameindex ltostr malloc-debugger md5_testharness \ +glob grent hasmntopt hello iconv if_nameindex ltostr malloc-debugger math md5_testharness \ memccpy memchr memcmp 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 strncat strncpy strptime strrchr \ --strstr strtol sysenter ungetc waitpid +-protoent prototypes putenv pwent rand48 read1 readdir regex select sendfile servent siglist \ +-speed spent sprintf sscanf stdarg strcasecmp strcmp strncat strncpy strptime strrchr \ +-strstr strtol sysenter ungetc utime waitpid ++protoent prototypes putenv pwent rand48 read1 readdir regex select sendfile servent setjmp siglist \ ++sigsetjmp speed spent sprintf sscanf stdarg strcasecmp strcmp strncat strncpy strptime strrchr \ +strstr strtol sysconf sysenter ungetc utime waitpid test: $(TESTPROGRAMS) @@ -2802,76 +2659,6 @@ index d42d129..8d7a016 100644 + printf("%lu/%d\n", (unsigned long)b.tv_sec, (int)b.tv_usec); return 0; } -diff --git a/test/alarm.c b/test/alarm.c -new file mode 100644 -index 0000000..d1e13ce ---- /dev/null -+++ b/test/alarm.c -@@ -0,0 +1,64 @@ -+#include -+#include -+ -+#include -+#include -+#include -+ -+static volatile int alrm_triggered; -+ -+static void sig_alrm(int s) -+{ -+ alrm_triggered = 1; -+} -+ -+int main() -+{ -+ int rc; -+ time_t end; -+ sighandler_t old_sig; -+ -+ alarm(50); -+ -+ old_sig = signal(SIGALRM, &sig_alrm); -+ assert(old_sig != SIG_ERR); -+ -+ /* check whether alarm() returns correct number of remaining -+ * seconds */ -+ rc = alarm(2); -+ assert(rc > 40 && rc <= 50); -+ -+ /* check whether SIGALRM is triggered within the set time */ -+ end = time(NULL) + 5; -+ while (!alrm_triggered && time(NULL) < end) { -+ /* noop */ -+ } -+ assert(alrm_triggered); -+ -+ /* there should be no pending alarm */ -+ rc = alarm(0); -+ assert(rc == 0); -+ -+ alrm_triggered = 0; -+ -+ /* test whether alarm can be canceled */ -+ rc = alarm(2); -+ assert(rc == 0); -+ -+ rc = alarm(0); -+ assert(rc > 0 && rc < 4); -+ assert(!alrm_triggered); -+ -+ /* there should not happen an alarm */ -+ end = time(NULL) + 5; -+ while (!alrm_triggered && time(NULL) < end) { -+ /* noop */ -+ } -+ assert(!alrm_triggered); -+ -+ /* there should be no pending alarm */ -+ rc = alarm(0); -+ assert(rc == 0); -+ -+ return EXIT_SUCCESS; -+} diff --git a/test/asprintf.c b/test/asprintf.c index 996a5aa..0d4f2eb 100644 --- a/test/asprintf.c @@ -2963,30 +2750,62 @@ index 0000000..eea7a22 @@ -0,0 +1,2 @@ +/opendir-tst1 +/tst-seekdir -diff --git a/test/fadvise.c b/test/fadvise.c +diff --git a/test/ftruncate.c b/test/ftruncate.c new file mode 100644 -index 0000000..cdd6428 +index 0000000..53b70bd --- /dev/null -+++ b/test/fadvise.c -@@ -0,0 +1,21 @@ ++++ b/test/ftruncate.c +@@ -0,0 +1,53 @@ +#define _GNU_SOURCE +#define _XOPEN_SOURCE 600 ++#define _FILE_OFFSET_BITS 64 + +#include +#include +#include +#include + ++#define CHECK(_sz) \ ++ assert(ftruncate(fd, (_sz)) == 0); \ ++ assert(fstat(fd, &st) == 0); \ ++ assert(st.st_size == (_sz)); \ ++ ++#define CHECK64(_sz) \ ++ assert(ftruncate64(fd, (_sz)) == 0); \ ++ assert(fstat64(fd, &st64) == 0); \ ++ assert(st64.st_size == (_sz)); \ ++ +int main(void) +{ + char file[] = "/tmp/dietlibc-fadvise-test.XXXXXX"; + int fd; ++ struct stat st; + + fd = mkstemp(file); + unlink(file); + -+ assert(posix_fadvise(fd, 23, 42, POSIX_FADV_RANDOM) == 0); -+ close(fd); ++ assert(ftruncate(fd, 500000) == 0); ++ assert(fstat(fd, &st) == 0); ++ ++ if (st.st_blocks > 1) { ++ /* spare files not supported by filesystem :( */ ++ return EXIT_SUCCESS; ++ } ++ ++ CHECK(1); ++ CHECK(0x7fffffff); ++ ++#if __WORDSIZE == 32 ++ { ++ struct stat64 st64; ++ CHECK64(1); ++ CHECK64(0x7fffffff); ++ CHECK64(0x80000001ul); ++ CHECK64(0x17fffffffull); ++ } ++#else ++ CHECK(0x17fffffffull); ++#endif + + return EXIT_SUCCESS; +} @@ -3269,14 +3088,14 @@ index 4f5b08f..1e67632 100644 return 0; } diff --git a/test/runtests.sh b/test/runtests.sh -index 6d89efb..4703888 100644 +index d6fb19b..15b70b1 100644 --- a/test/runtests.sh +++ b/test/runtests.sh @@ -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 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" -+TESTPROGRAMS="adjtime alarm argv atexit bsearch byteswap calloc confstr empty fadvise 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 math md5_testharness memccpy memchr memcmp 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 sysconf sysenter ungetc utime waitpid" +-TESTPROGRAMS="adjtime alarm argv atexit bsearch byteswap calloc confstr empty fadvise 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 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 utime waitpid" ++TESTPROGRAMS="adjtime alarm argv atexit bsearch byteswap calloc confstr empty fadvise flush fputc ffs fnmatch ftruncate 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 math md5_testharness memccpy memchr memcmp memrchr memusage mktime mmap_test pipe printf printftest protoent prototypes putenv pwent rand48 readdir regex select sendfile servent setjmp siglist sigsetjmp speed spent sprintf sscanf stdarg strcasecmp strcmp strncat strncpy strptime strrchr strstr strtol sysconf sysenter ungetc utime waitpid" STDIN="read1" PASS="getpass" @@ -3291,6 +3110,264 @@ index d43cdd2..28b3af5 100644 -return 0; + return ret<0 ? 1 : 0; } +diff --git a/test/setjmp.c b/test/setjmp.c +new file mode 100644 +index 0000000..15951e5 +--- /dev/null ++++ b/test/setjmp.c +@@ -0,0 +1,106 @@ ++#include ++#include ++#include ++#include ++ ++static int Xmemcmp(void const volatile *a, void const volatile *b, size_t l) ++{ ++ return memcmp((void const *)a, (void const *)b, l); ++} ++ ++int main(void) ++{ ++ char volatile a[8] = "testbufA"; ++ jmp_buf env; ++ char volatile b[8] = "testbufB"; ++ ++ assert(Xmemcmp(a, "testbufA", 8) == 0); ++ assert(Xmemcmp(b, "testbufB", 8) == 0); ++ ++ ++ /* Test 1: not calling longjmp */ ++ if (setjmp(env) == 0) { ++ char volatile somebuf[128]; ++ ++ memset((void *)somebuf, 0xde, sizeof somebuf); ++ ++ assert(Xmemcmp(a, "testbufA", 8) == 0); ++ assert(Xmemcmp(b, "testbufB", 8) == 0); ++ } else ++ assert(0); ++ ++ assert(Xmemcmp(a, "testbufA", 8) == 0); ++ assert(Xmemcmp(b, "testbufB", 8) == 0); ++ ++ ++ /* Test 2: calling longjmp */ ++ switch (setjmp(env)) { ++ case 0: { ++ char volatile somebuf[128]; ++ ++ memset((void *)somebuf, 0xde, sizeof somebuf); ++ ++ assert(Xmemcmp(a, "testbufA", 8) == 0); ++ assert(Xmemcmp(b, "testbufB", 8) == 0); ++ ++ longjmp(env, 23); ++ ++ a[0] = 'X'; ++ b[0] = 'X'; ++ } ++ ++ case 23: ++ break; ++ ++ default: ++ assert(0); ++ } ++ ++ assert(Xmemcmp(a, "testbufA", 8) == 0); ++ assert(Xmemcmp(b, "testbufB", 8) == 0); ++ ++ ++ /* Test 3: calling longjmp again with dirty env */ ++ switch (setjmp(env)) { ++ case 0: { ++ char volatile somebuf[128]; ++ ++ memset((void *)somebuf, 0xde, sizeof somebuf); ++ ++ assert(Xmemcmp(a, "testbufA", 8) == 0); ++ assert(Xmemcmp(b, "testbufB", 8) == 0); ++ ++ longjmp(env, 23); ++ ++ a[0] = 'X'; ++ b[0] = 'X'; ++ } ++ ++ case 23: ++ break; ++ ++ default: ++ assert(0); ++ } ++ ++ assert(Xmemcmp(a, "testbufA", 8) == 0); ++ assert(Xmemcmp(b, "testbufB", 8) == 0); ++ ++ ++ /* Test 4: not calling longjmp, but dirty env */ ++ if (setjmp(env) == 0) { ++ char volatile somebuf[128]; ++ ++ memset((void *)somebuf, 0xde, sizeof somebuf); ++ ++ assert(Xmemcmp(a, "testbufA", 8) == 0); ++ assert(Xmemcmp(b, "testbufB", 8) == 0); ++ } else ++ assert(0); ++ ++ assert(Xmemcmp(a, "testbufA", 8) == 0); ++ assert(Xmemcmp(b, "testbufB", 8) == 0); ++ ++ ++ return EXIT_SUCCESS; ++} +diff --git a/test/sigsetjmp.c b/test/sigsetjmp.c +new file mode 100644 +index 0000000..3fa71bb +--- /dev/null ++++ b/test/sigsetjmp.c +@@ -0,0 +1,140 @@ ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#define TEST_PATTERN \ ++ "0123456789abcdefghijklmnopqrstuv" \ ++ "ZYXWVUTSRQPONMLKJIHGFEDCBA987654" \ ++ "456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" \ ++ "vutsrqponmlkjihgfedcba9876543210" \ ++ "0123456789ABCDEFGHIJKLMNOPQRSTUV" \ ++ "zyxwvutsrqponmlkjihgfedcba987654" \ ++ "456789abcdefghijklmnopqrstuvwxyz" \ ++ "VUTSRQPONMLKJIHGFEDCBA987654321" \ ++ ++static struct { ++ char volatile a[256]; ++ sigjmp_buf env; ++ char volatile b[256]; ++} sigenv = { ++ .a = TEST_PATTERN "<", ++ .b = TEST_PATTERN ">", ++}; ++ ++static int volatile sig_seen; ++ ++#define VALIDATE_BUFFERS(_sig_exp) do { \ ++ assert(Xmemcmp(sigenv.a, TEST_PATTERN "<", sizeof sigenv.a) == 0); \ ++ assert(Xmemcmp(sigenv.b, TEST_PATTERN ">", sizeof sigenv.b) == 0); \ ++ assert(sig_seen == (_sig_exp)); \ ++ } while (0) ++ ++static int Xmemcmp(void const volatile *a, void const volatile *b, size_t l) ++{ ++ return memcmp((void const *)a, (void const *)b, l); ++} ++ ++static void do_test(int sig_num, int do_save, int block_sig) ++{ ++ int rc; ++ sigset_t block_set; ++ sigset_t cur_set; ++ ++ printf("%s(%d,%d,%d)... ", __func__, sig_num, do_save, block_sig); ++ fflush(stdout); ++ ++ VALIDATE_BUFFERS(0); ++ ++ sigemptyset(&block_set); ++ assert(sigprocmask(SIG_SETMASK, NULL, &cur_set) == 0); ++ ++ /* verify that tested signal is not blocked */ ++ if (sig_num != 0) ++ assert(!sigismember(&cur_set, sig_num)); ++ ++ /* verify that blocked signal is not already blocked and fill signal set */ ++ if (block_sig != 0) { ++ assert(!sigismember(&cur_set, block_sig)); ++ sigaddset(&block_set, block_sig); ++ } ++ ++ sig_seen = 0; ++ rc = sigsetjmp(sigenv.env, do_save); ++ if (rc == 0) { ++ char volatile somebuf[128]; ++ ++ memset((void *)somebuf, 0x42, sizeof somebuf); ++ VALIDATE_BUFFERS(0); ++ ++ /* modify signal mask */ ++ if (block_sig != 0) ++ assert(sigprocmask(SIG_BLOCK, &block_set, NULL) == 0); ++ ++ /* raise a signal which triggers a siglongjmp */ ++ if (sig_num != 0) { ++ raise(sig_num); ++ sigenv.a[0] = 'X'; ++ sigenv.b[0] = 'X'; ++ assert(0); ++ } ++ } else if (rc != sig_num) ++ /* sigsetjmp() returned with an unexpected value */ ++ assert(0); ++ ++ VALIDATE_BUFFERS(sig_num); ++ sig_seen = 0; ++ ++ /* check whether current signal mask contains the blocked signal; it should ++ be there iff sigsetjmp() was triggered and sigmask was saved. */ ++ if (block_sig != 0) { ++ sigset_t cur_set; ++ assert(sigprocmask(SIG_SETMASK, NULL, &cur_set) == 0); ++ ++ if (do_save && rc != 0) ++ assert(!sigismember(&cur_set, block_sig)); ++ else { ++ assert( sigismember(&cur_set, block_sig)); ++ sigprocmask(SIG_UNBLOCK, &block_set, NULL); ++ } ++ } ++ ++ printf(" ok\n"); ++}; ++ ++static void sig_handler(int num) ++{ ++ assert(sig_seen == 0); ++ sig_seen = num; ++ siglongjmp(sigenv.env, num); ++} ++ ++int main(void) ++{ ++ struct sigaction sigact = { ++ .sa_handler = sig_handler, ++ .sa_flags = SA_NODEFER, /* raised signal will be in blocked mask else */ ++ }; ++ ++ /* verify our assumptions about the memory layout */ ++ assert(sizeof sigenv.a == 256); ++ assert(sizeof sigenv.b == 256); ++ assert(offsetof(__typeof__(sigenv), env) == sizeof sigenv.a); ++ assert(offsetof(__typeof__(sigenv), b) == sizeof sigenv.a + sizeof sigenv.env); ++ ++ sigaction(SIGBUS, &sigact, NULL); ++ sigaction(SIGUSR1, &sigact, NULL); ++ ++ do_test(0, 0, 0); ++ do_test(0, 0, SIGUSR1); ++ do_test(0, 1, 0); ++ do_test(0, 1, SIGUSR1); ++ do_test(SIGBUS, 0, 0); ++ do_test(SIGBUS, 0, SIGUSR1); ++ do_test(SIGBUS, 1, 0); ++ do_test(SIGBUS, 1, SIGUSR1); ++ ++ return EXIT_SUCCESS; ++} diff --git a/test/speed.c b/test/speed.c index 674b9a8..22249a7 100644 --- a/test/speed.c @@ -3664,49 +3741,6 @@ index 6277ea6..2773180 100644 { printf ("not all of `%s' read\n", day_tests[i].input); result = 1; -diff --git a/test/utime.c b/test/utime.c -new file mode 100644 -index 0000000..955ac6f ---- /dev/null -+++ b/test/utime.c -@@ -0,0 +1,37 @@ -+#include -+#include -+#include -+#include -+#include -+ -+int main(void) -+{ -+ char file[] = "/tmp/utime-test.XXXXXX"; -+ int tmp_fd; -+ struct utimbuf utm = { -+ .actime = 23, -+ .modtime = 42, -+ }; -+ struct stat st; -+ time_t now; -+ -+ tmp_fd = mkstemp(file); -+ close(tmp_fd); -+ -+ assert(utime(file, &utm) == 0); -+ assert(stat(file, &st) == 0); -+ assert(st.st_atime == utm.actime); -+ assert(st.st_mtime == utm.modtime); -+ -+ now = time(NULL); -+ assert(utime(file, NULL) == 0); -+ assert(stat(file, &st) == 0); -+ -+ assert(st.st_atime == st.st_mtime); -+ assert(st.st_atime >= now); -+ assert(st.st_atime - now < 10); -+ -+ unlink(file); -+ -+ return EXIT_SUCCESS; -+} diff --git a/test/waitpid.c b/test/waitpid.c index fe2cb5b..92c0b0e 100644 --- a/test/waitpid.c @@ -3722,28 +3756,18 @@ index fe2cb5b..92c0b0e 100644 } diff --git a/x86_64/__time.S b/x86_64/__time.S new file mode 100644 -index 0000000..9d2d4b4 +index 0000000..774b67f --- /dev/null +++ b/x86_64/__time.S -@@ -0,0 +1,21 @@ +@@ -0,0 +1,11 @@ +/* implement time(2) via gettimeofday(2) on x86-64 because gettimeofday + is a vsyscall (i.e. no actual switch to kernel mode) */ +.text +.global time +.type time,@function +time: -+ push %rdi -+ xor %rsi,%rsi -+ sub $16,%rsp -+ mov %rsp,%rdi -+ call gettimeofday -+ pop %rax -+ pop %rdi -+ pop %rdi -+ test %rdi,%rdi -+ jz 1f -+ mov %rax,(%rdi) -+1: ++ mov $0xffffffffff600400,%rax ++ call *%rax + ret +.Lhere: + .size time,.Lhere-time @@ -3781,29 +3805,19 @@ index adc461a..8b4f3c9 100644 #ifdef PROFILING pushq %rdi /* save reg args */ diff --git a/x86_64/time.S b/x86_64/time.S -index 9d2d4b4..dbe7894 100644 +index 774b67f..690ee30 100644 --- a/x86_64/time.S +++ b/x86_64/time.S -@@ -1,21 +1 @@ +@@ -1,11 +1 @@ -/* implement time(2) via gettimeofday(2) on x86-64 because gettimeofday - is a vsyscall (i.e. no actual switch to kernel mode) */ -.text -.global time -.type time,@function -time: -- push %rdi -- xor %rsi,%rsi -- sub $16,%rsp -- mov %rsp,%rdi -- call gettimeofday -- pop %rax -- pop %rdi -- pop %rdi -- test %rdi,%rdi -- jz 1f -- mov %rax,(%rdi) --1: +- mov $0xffffffffff600400,%rax +- call *%rax - ret -.Lhere: - .size time,.Lhere-time -+ .text /* avoid empty source file */ ++/* avoid empty source file */ diff --git a/dietlibc.spec b/dietlibc.spec index 30ee522..6b85fab 100644 --- a/dietlibc.spec +++ b/dietlibc.spec @@ -7,7 +7,7 @@ %bcond_without noarch ## -%global prerelease 20101223 +%global prerelease 20110311 %global pkglibdir %_prefix/lib/dietlibc %ifarch %ix86 x86_64 @@ -198,6 +198,10 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Sat Mar 12 2011 Enrico Scholz - 0.33-0.1600.20110311 +- updated to 20110311 CVS snapshot +- rediffed patches + * Sun Feb 20 2011 Enrico Scholz - 0.33-0.1600.20101223 - other ARM enhancements - fixed missing headers in last utime(2) + fadvise(2) patches diff --git a/sources b/sources index 87c5fef..626985e 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -44df912e2af432a413930387537d6bb2 dietlibc-0.33.20101223.tar.bz2 +5b0f5f5433db773cd9185c8ed79374f0 dietlibc-0.33.20110311.tar.bz2