diff -uNr dietlibc-0.25/CHANGES dietlibc-0.26/CHANGES --- dietlibc-0.25/CHANGES Thu Mar 25 22:11:00 2004 +++ dietlibc-0.26/CHANGES Thu Jun 3 13:37:04 2004 @@ -1,3 +1,23 @@ +0.26: + iconv UTF-8 fix (Kuba Winnicki) + Olaf: + - add 'getgrouplist' + - fix type of 'unsetenv' + - add missing realtime syscalls 'clock_*' 'timer_*' and types + ARGH! gcc 3.4 breaks regparm attributes on i386! + grep portability fixes (Gunnar Ritter) + add empty libcrypt.a to help compile code from others (Gunnar Ritter) + add make uninstall + fix pread64, pwrite64 + Olaf: MIPS has a special case for the pread/pwrite syscall ... + Use -isystem instead of -I for our system includes (Paul Jarc) + Add MNT_DETACH to sys/mount.h + add pselect + fix for tzfile (Felix J. Ogris) + add res_close to close the DNS UDP sockets + remove ia64/waitpid.S; it was broken and there is a working C version + (Gerrit Pape) + 0.25: fix sprintf head -1 -> head -n 1 diff -uNr dietlibc-0.25/Makefile dietlibc-0.26/Makefile --- dietlibc-0.25/Makefile Fri Mar 26 16:28:44 2004 +++ dietlibc-0.26/Makefile Tue May 11 14:48:16 2004 @@ -88,6 +88,7 @@ $(OBJDIR)/dietlibc.a $(OBJDIR)/liblatin1.a \ $(OBJDIR)/libcompat.a $(OBJDIR)/libm.a \ $(OBJDIR)/librpc.a $(OBJDIR)/libpthread.a \ + $(OBJDIR)/libcrypt.a \ $(OBJDIR)/diet $(OBJDIR)/diet-i $(OBJDIR)/elftrunc all: $(WHAT) @@ -133,7 +134,7 @@ CFLAGS = -g COMMENT = : endif -CFLAGS += -Wall -W -Wchar-subscripts -Wmissing-prototypes -Wmissing-declarations -Wno-switch -Wredundant-decls -Wno-unused +CFLAGS += -Wall -W -Wchar-subscripts -Wmissing-prototypes -Wmissing-declarations -Wno-switch -Wno-unused -Wredundant-decls PWD=$(shell pwd) @@ -149,17 +150,17 @@ % :: %,v $(OBJDIR)/pstart.o: start.S - $(CROSS)$(CC) -I. -Iinclude $(CFLAGS) -DPROFILING -c $< -o $@ + $(CROSS)$(CC) -I. -isystem include $(CFLAGS) -DPROFILING -c $< -o $@ $(OBJDIR)/%.o: %.S $(ARCH)/syscalls.h - $(CROSS)$(CC) -I. -Iinclude $(CFLAGS) -c $< -o $@ + $(CROSS)$(CC) -I. -isystem include $(CFLAGS) -c $< -o $@ $(OBJDIR)/pthread_%.o: libpthread/pthread_%.c - $(CROSS)$(CC) -I. -Iinclude $(CFLAGS) -c $< -o $@ + $(CROSS)$(CC) -I. -isystem include $(CFLAGS) -c $< -o $@ $(COMMENT) -$(CROSS)strip -x -R .comment -R .note $@ $(OBJDIR)/%.o: %.c - $(CROSS)$(CC) -I. -Iinclude $(CFLAGS) -c $< -o $@ + $(CROSS)$(CC) -I. -isystem include $(CFLAGS) -c $< -o $@ $(COMMENT) -$(CROSS)strip -x -R .comment -R .note $@ DIETLIBC_OBJ = $(OBJDIR)/unified.o \ @@ -174,6 +175,14 @@ $(OBJDIR)/librpc.a: $(LIBRPCOBJ) $(CROSS)ar cru $@ $(LIBRPCOBJ) +$(OBJDIR)/libcrypt.a: + touch dummy.c + $(CROSS)gcc -c dummy.c + $(CROSS)ar cru $@ dummy.o + rm -f dummy.c dummy.o + +dummy.o: + LIBLATIN1_OBJS=$(patsubst liblatin1/%.c,$(OBJDIR)/%.o,$(wildcard liblatin1/*.c)) $(OBJDIR)/liblatin1.a: $(LIBLATIN1_OBJS) $(CROSS)ar cru $@ $^ @@ -205,21 +214,21 @@ $(PICODIR)/diet-dyn $(PICODIR)/diet-dyn-i $(PICODIR)/%.o: %.S $(ARCH)/syscalls.h - $(CROSS)$(CC) -I. -Iinclude $(CFLAGS) -fPIC -D__DYN_LIB -c $< -o $@ + $(CROSS)$(CC) -I. -isystem include $(CFLAGS) -fPIC -D__DYN_LIB -c $< -o $@ $(PICODIR)/pthread_%.o: libpthread/pthread_%.c - $(CROSS)$(CC) -I. -Iinclude $(CFLAGS) -fPIC -D__DYN_LIB -c $< -o $@ + $(CROSS)$(CC) -I. -isystem include $(CFLAGS) -fPIC -D__DYN_LIB -c $< -o $@ $(COMMENT) $(CROSS)strip -x -R .comment -R .note $@ $(PICODIR)/%.o: %.c - $(CROSS)$(CC) -I. -Iinclude $(CFLAGS) -fPIC -D__DYN_LIB -c $< -o $@ + $(CROSS)$(CC) -I. -isystem include $(CFLAGS) -fPIC -D__DYN_LIB -c $< -o $@ $(COMMENT) $(CROSS)strip -x -R .comment -R .note $@ $(PICODIR)/dstart.o: start.S - $(CROSS)$(CC) -I. -Iinclude $(CFLAGS) -fPIC -D__DYN_LIB -c $< -o $@ + $(CROSS)$(CC) -I. -isystem include $(CFLAGS) -fPIC -D__DYN_LIB -c $< -o $@ $(PICODIR)/dyn_so_start.o: dyn_start.c - $(CROSS)$(CC) -I. -Iinclude $(CFLAGS) -fPIC -D__DYN_LIB -D__DYN_LIB_SHARED -c $< -o $@ + $(CROSS)$(CC) -I. -isystem include $(CFLAGS) -fPIC -D__DYN_LIB -D__DYN_LIB_SHARED -c $< -o $@ $(COMMENT) $(CROSS)strip -x -R .comment -R .note $@ DYN_LIBC_PIC = $(LIBOBJ) $(LIBSTDIOOBJ) $(LIBUGLYOBJ) \ @@ -241,7 +250,7 @@ $(CROSS)$(CC) -nostdlib -shared -o $@ $(CFLAGS) -fPIC $(DYN_PTHREAD_OBJS) -L$(PICODIR) -lc -Wl,-soname=libpthread.so $(PICODIR)/libdl.so: libdl/_dl_main.c dietfeatures.h - $(CROSS)$(CC) -D__OD_CLEAN_ROOM -DNODIETREF -fPIC -nostdlib -shared -o $@ $(CFLAGS) -I. -Iinclude libdl/_dl_main.c -Wl,-soname=libdl.so + $(CROSS)$(CC) -D__OD_CLEAN_ROOM -DNODIETREF -fPIC -nostdlib -shared -o $@ $(CFLAGS) -I. -isystem include libdl/_dl_main.c -Wl,-soname=libdl.so #$(PICODIR)/libdl.so: $(DYN_LIBDL_OBJS) dietfeatures.h # $(CROSS)$(CC) -nostdlib -shared -o $@ $(CFLAGS) -fPIC $(DYN_LIBDL_OBJS) -L$(PICODIR) -ldietc -Wl,-soname=libdl.so @@ -260,19 +269,19 @@ CURNAME=$(notdir $(shell pwd)) $(OBJDIR)/diet: $(OBJDIR)/start.o $(OBJDIR)/dyn_start.o diet.c $(OBJDIR)/dietlibc.a $(OBJDIR)/dyn_stop.o - $(CROSS)$(CC) -Iinclude $(CFLAGS) -nostdlib -o $@ $^ -DDIETHOME=\"$(HOME)\" -DVERSION=\"$(VERSION)\" -lgcc + $(CROSS)$(CC) -isystem include $(CFLAGS) -nostdlib -o $@ $^ -DDIETHOME=\"$(HOME)\" -DVERSION=\"$(VERSION)\" -lgcc $(CROSS)strip -R .comment -R .note $@ $(OBJDIR)/diet-i: $(OBJDIR)/start.o $(OBJDIR)/dyn_start.o diet.c $(OBJDIR)/dietlibc.a $(OBJDIR)/dyn_stop.o - $(CROSS)$(CC) -Iinclude $(CFLAGS) -nostdlib -o $@ $^ -DDIETHOME=\"$(prefix)\" -DVERSION=\"$(VERSION)\" -DINSTALLVERSION -lgcc + $(CROSS)$(CC) -isystem include $(CFLAGS) -nostdlib -o $@ $^ -DDIETHOME=\"$(prefix)\" -DVERSION=\"$(VERSION)\" -DINSTALLVERSION -lgcc $(CROSS)strip -R .comment -R .note $@ $(PICODIR)/diet-dyn: $(PICODIR)/start.o $(PICODIR)/dyn_start.o diet.c - $(CROSS)$(CC) -Iinclude $(CFLAGS) -fPIC -nostdlib -o $@ $^ -DDIETHOME=\"$(HOME)\" -D__DYN_LIB -DVERSION=\"$(VERSION)\" -L$(PICODIR) -lc -lgcc $(PICODIR)/dyn_stop.o -Wl,-dynamic-linker=$(HOME)/$(PICODIR)/libdl.so + $(CROSS)$(CC) -isystem include $(CFLAGS) -fPIC -nostdlib -o $@ $^ -DDIETHOME=\"$(HOME)\" -D__DYN_LIB -DVERSION=\"$(VERSION)\" -L$(PICODIR) -lc -lgcc $(PICODIR)/dyn_stop.o -Wl,-dynamic-linker=$(HOME)/$(PICODIR)/libdl.so $(CROSS)strip -R .command -R .note $@ $(PICODIR)/diet-dyn-i: $(PICODIR)/start.o $(PICODIR)/dyn_start.o diet.c - $(CROSS)$(CC) -Iinclude $(CFLAGS) -fPIC -nostdlib -o $@ $^ -DDIETHOME=\"$(prefix)\" -D__DYN_LIB -DVERSION=\"$(VERSION)\" -L$(PICODIR) -lc -lgcc $(PICODIR)/dyn_stop.o -Wl,-dynamic-linker=$(ILIBDIR)/libdl.so -DINSTALLVERSION + $(CROSS)$(CC) -isystem include $(CFLAGS) -fPIC -nostdlib -o $@ $^ -DDIETHOME=\"$(prefix)\" -D__DYN_LIB -DVERSION=\"$(VERSION)\" -L$(PICODIR) -lc -lgcc $(PICODIR)/dyn_stop.o -Wl,-dynamic-linker=$(ILIBDIR)/libdl.so -DINSTALLVERSION $(CROSS)strip -R .command -R .note $@ $(OBJDIR)/djb: $(OBJDIR)/compile $(OBJDIR)/load @@ -299,11 +308,11 @@ if test $(CURNAME) != $(VERSION); then cd .. && mv $(CURNAME) $(VERSION); fi $(OBJDIR)/exports: $(OBJDIR)/dietlibc.a - nm -g $(OBJDIR)/dietlibc.a | grep -w T | awk '{ print $$3 }' | sort -u > $(OBJDIR)/exports + nm -g $(OBJDIR)/dietlibc.a | grep '\' | awk '{ print $$3 }' | sort -u > $(OBJDIR)/exports .PHONY: t t1 t: - $(CROSS)$(CC) -g $(CFLAGS) -fno-builtin -nostdlib -Iinclude -o t t.c $(OBJDIR)/start.o $(OBJDIR)/dyn_start.o $(OBJDIR)/dietlibc.a -lgcc $(OBJDIR)/dyn_stop.o -Wl,-Map,mapfile + $(CROSS)$(CC) -g $(CFLAGS) -fno-builtin -nostdlib -isystem include -o t t.c $(OBJDIR)/start.o $(OBJDIR)/dyn_start.o $(OBJDIR)/dietlibc.a -lgcc $(OBJDIR)/dyn_stop.o -Wl,-Map,mapfile t1: $(CROSS)$(CC) -g -o t1 t.c @@ -312,7 +321,7 @@ $(INSTALL) -d $(DESTDIR)$(ILIBDIR) $(DESTDIR)$(MAN1DIR) $(DESTDIR)$(BINDIR) $(INSTALL) $(OBJDIR)/start.o $(DESTDIR)$(ILIBDIR)/start.o $(INSTALL) -m 644 $(OBJDIR)/libm.a $(OBJDIR)/libpthread.a $(OBJDIR)/librpc.a \ -$(OBJDIR)/liblatin1.a $(OBJDIR)/libcompat.a $(DESTDIR)$(ILIBDIR) +$(OBJDIR)/liblatin1.a $(OBJDIR)/libcompat.a $(OBJDIR)/libcrypt.a $(DESTDIR)$(ILIBDIR) $(INSTALL) -m 644 $(OBJDIR)/dietlibc.a $(DESTDIR)$(ILIBDIR)/libc.a ifeq ($(MYARCH),$(ARCH)) $(INSTALL) $(OBJDIR)/diet-i $(DESTDIR)$(BINDIR)/diet @@ -330,6 +339,14 @@ if test -f $(PICODIR)/libc.so -a ! -f $(DESTDIR)/etc/diet.ld.conf; then echo "$(ILIBDIR)" > $(DESTDIR)/etc/diet.ld.conf; fi for i in `find include -name \*.h`; do install -m 644 -D $$i $(DESTDIR)$(prefix)/$$i; done +uninstall: + for i in start.o libm.a libpthread.a librpc.a liblatin1.a libcompat.a libcrypt.a libc.a; do rm -f $(DESTDIR)$(ILIBDIR)/$$i; done + rm -f $(DESTDIR)$(BINDIR)/diet $(DESTDIR)$(BINDIR)/diet-dyn + for i in libgmon.a dyn_start.o dyn_stop.o libc.so libpthread.so libdl.so libcompat.so dyn_dstart.o dyn_dstop.o dyn_so_start.o; do rm -f $(DESTDIR)$(ILIBDIR)/$$i; done + rm -f $(DESTDIR)$(MAN1DIR)/diet.1 $(DESTDIR)/etc/diet.ld.conf + for i in `find include -name \*.h`; do rm -f $(DESTDIR)$(prefix)/$$i; done + -rmdir $(DESTDIR)$(ILIBDIR) $(DESTDIR)$(MAN1DIR) $(DESTDIR)$(BINDIR) + .PHONY: sparc ppc mips arm alpha i386 parisc mipsel powerpc s390 sparc64 .PHONY: x86_64 ia64 diff -uNr dietlibc-0.25/__waitpid.s dietlibc-0.26/__waitpid.s --- dietlibc-0.25/__waitpid.s Thu Jan 1 01:00:00 1970 +++ dietlibc-0.26/__waitpid.s Thu Jun 3 13:08:31 2004 @@ -0,0 +1,39 @@ + .file "__waitpid.c" + .pred.safe_across_calls p1-p5,p16-p63 + .text + .align 16 + .global waitpid# + .proc waitpid# +waitpid: + .prologue 12, 35 + .mmi + .save ar.pfs, r36 + alloc r36 = ar.pfs, 3, 3, 4, 0 + mov r37 = r1 + .save rp, r35 + mov r35 = b0 + .body + .mmi + mov r38 = r32 + mov r39 = r33 + mov r40 = r34 + .mmb + nop 0 + mov r41 = r0 + nop 0 + ;; + .bbb + nop 0 + nop 0 + br.call.sptk.many b0 = wait4# + ;; + .mmi + nop 0 + mov r1 = r37 + mov b0 = r35 + .mib + nop 0 + mov ar.pfs = r36 + br.ret.sptk.many b0 + .endp waitpid# + .ident "GCC: (GNU) 3.4.0" diff -uNr dietlibc-0.25/contrib/Makefile dietlibc-0.26/contrib/Makefile --- dietlibc-0.25/contrib/Makefile Thu Jan 1 01:00:00 1970 +++ dietlibc-0.26/contrib/Makefile Sat Sep 20 02:06:32 2003 @@ -0,0 +1,2 @@ +pnpdnsd: pnpdnsd.c + diet gcc -g -o $@ $^ diff -uNr dietlibc-0.25/contrib/pnpdnsd.c dietlibc-0.26/contrib/pnpdnsd.c --- dietlibc-0.25/contrib/pnpdnsd.c Thu Jan 1 01:00:00 1970 +++ dietlibc-0.26/contrib/pnpdnsd.c Sat Sep 20 20:03:27 2003 @@ -0,0 +1,117 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int main(int argc,char* argv[]) { + int pnpfd; + struct sockaddr_in6 pnpsa; + struct pollfd pfd; + struct ipv6_mreq opt; + unsigned int interface=0; + unsigned char inpkg[4095]; + + if (argc<2) { + puts("usage: pnpdnsd eth0"); + return 111; + } + interface=if_nametoindex(argv[1]); + if (interface==0) { + puts("pnpdnsd: network interface not found!"); + return 111; + } + pnpfd=socket(PF_INET6,SOCK_DGRAM,IPPROTO_UDP); + + /* bind to port 53 */ + memset(&pnpsa,0,sizeof(struct sockaddr_in6)); + pnpsa.sin6_family=AF_INET6; + pnpsa.sin6_port=htons(53); + pnpsa.sin6_scope_id=interface; + if (bind(pnpfd,(struct sockaddr*)&pnpsa,sizeof(pnpsa))) { + perror("bind"); + return 111; + } + + /* join the multicast group */ + memmove(&opt.ipv6mr_multiaddr,"\xff\x02\x00\x00\x00\x00\x00\x00\x00\x00dnspnp",16); + opt.ipv6mr_interface=interface; + if (setsockopt(pnpfd,IPPROTO_IPV6,IPV6_ADD_MEMBERSHIP,&opt,sizeof opt)==-1) { + perror("setsockopt"); + return 111; + } + + { + socklen_t len=sizeof(pnpsa); + if (getsockname(pnpfd,(struct sockaddr*)&pnpsa,&len)==-1) { + perror("getsockname"); + return 111; + } + } + + for (;;) { + int len; + int fromlen; + int qdcount; + struct sockaddr_in6 peersa; + fromlen=sizeof(peersa); + len=recvfrom(pnpfd,inpkg,sizeof(inpkg),0,(struct sockaddr*)&peersa,&fromlen); + if (len==-1) { + perror("recvfrom"); + return 111; + } + + /* is it a recursive query, as libresolv would issue? */ + if (inpkg[2]!=1) continue; + + qdcount=((unsigned long)(inpkg[4])<<8) + inpkg[5]; + + { + int decofs; + char name[257]; + char myname[257]; + struct utsname u; + decofs=dn_expand(inpkg,inpkg+len,inpkg+12,name,sizeof(name)-1); + puts(name); + uname(&u); + if (strlen(u.nodename)>63) u.nodename[63]=0; + if (!strcasecmp(u.nodename,name)) { + char packet[1500]; + char* c; + packet[0]=inpkg[0]; + packet[1]=inpkg[1]; + packet[2]=inpkg[2] | 0x84; + packet[3]=0; + memset(packet+4,0,8); + packet[7]=1; + packet[12]=strlen(u.nodename); + strcpy(packet+13,u.nodename); + c=packet+14+strlen(u.nodename); + if (((long)c)&1) { *c=0; ++c; } + /* int16 type */ + c[0]=0; c[1]=28; /* AAAA */ + /* int16 class */ + c[2]=0; c[3]=1; /* IN */ + /* int32 ttl */ + c[4]=0; c[5]=0; c[6]=0; c[7]=23; /* 23 seconds TTL */ + /* int16 rdlength */ + c[8]=0; c[9]=16; + /* int16 rdata */ + memmove(c+10,&pnpsa.sin6_addr,16); + + if (sendto(pnpfd,packet,c+26-packet,0,(struct sockaddr*)&peersa,fromlen)==-1) + perror("sendto"); + } + } + } +} diff -uNr dietlibc-0.25/diet.c dietlibc-0.26/diet.c --- dietlibc-0.25/diet.c Mon Dec 15 13:32:52 2003 +++ dietlibc-0.26/diet.c Tue May 11 14:48:16 2004 @@ -219,7 +219,7 @@ b=alloca(strlen(platform)+20); c=alloca(strlen(platform)+20); - strcpy(a,"-I"); strcat(a,diethome); strcat(a,"/include"); + strcpy(a,diethome); strcat(a,"/include"); #ifndef __DYN_LIB strcpy(b,platform); if (profile) strcat(b,"/pstart.o"); else strcat(b,"/start.o"); @@ -284,9 +284,15 @@ *dest++=argv[i]; } #ifndef __DYN_LIB - if (compile || _link) *dest++=a; + if (compile || _link) { + *dest++="-isystem"; + *dest++=a; + } #else - if (compile || _link || shared) *dest++=a; + if (compile || _link || shared) { + *dest++="-isystem"; + *dest++=a; + } #endif *dest++="-D__dietlibc__"; if (mangleopts) { diff -uNr dietlibc-0.25/dietuglyweaks.h dietlibc-0.26/dietuglyweaks.h --- dietlibc-0.25/dietuglyweaks.h Mon Oct 13 16:39:23 2003 +++ dietlibc-0.26/dietuglyweaks.h Thu Apr 29 17:23:13 2004 @@ -4,23 +4,26 @@ /* if you change something here ... KNOW what you're doing ! * it'll effect ALL platforms ! */ -.weak __thread_doexit -__thread_doexit: -.weak __fflush_stdin -__fflush_stdin: -.weak __fflush_stdout -__fflush_stdout: -.weak __fflush_stderr -__fflush_stderr: -.weak flockfile -flockfile: -.weak ftrylockfile -ftrylockfile: -.weak funlockfile -funlockfile: -.weak __nop -__nop: -.global __you_tried_to_link_a_dietlibc_object_against_glibc -__you_tried_to_link_a_dietlibc_object_against_glibc: +.macro DEF_G name +.global \name +.type \name,function +\name: +.endm +.macro DEF_W name +.weak \name +.type \name,function +\name: +.endm + +DEF_W __fflush_stderr +DEF_W __fflush_stdin +DEF_W __fflush_stdout +DEF_W __nop +DEF_W __thread_doexit +DEF_W flockfile +DEF_W ftrylockfile +DEF_W funlockfile + +DEF_G __you_tried_to_link_a_dietlibc_object_against_glibc #endif diff -uNr dietlibc-0.25/i386/PIC.h dietlibc-0.26/i386/PIC.h --- dietlibc-0.25/i386/PIC.h Fri Nov 15 16:39:17 2002 +++ dietlibc-0.26/i386/PIC.h Thu Apr 29 17:23:13 2004 @@ -4,6 +4,21 @@ #if 1 /* don't trash the athlon return stack */ +#if (__GNUC__ >= 3) // FIXME: how do I check for the binutils version ? +.section .gnu.linkonce.t.__i686.get_pc_thunk.bx,"ax",@progbits +.global __i686.get_pc_thunk.bx +.hidden __i686.get_pc_thunk.bx +.type __i686.get_pc_thunk.bx,@function +__i686.get_pc_thunk.bx: + movl (%esp), %ebx + ret +.previous + +.macro PIC_INIT + call __i686.get_pc_thunk.bx + addl $_GLOBAL_OFFSET_TABLE_, %ebx +.endm +#else .text .Lgetpic: mov (%esp),%ebx @@ -13,6 +28,7 @@ call .Lgetpic addl $_GLOBAL_OFFSET_TABLE_, %ebx .endm +#endif #else /* standard code for PIC init */ .macro PIC_INIT diff -uNr dietlibc-0.25/i386/dyn_syscalls.S dietlibc-0.26/i386/dyn_syscalls.S --- dietlibc-0.25/i386/dyn_syscalls.S Thu Jan 15 18:35:43 2004 +++ dietlibc-0.26/i386/dyn_syscalls.S Thu Apr 29 17:23:13 2004 @@ -83,10 +83,12 @@ .weak exit exit: .type _exit,@function +.type __exit,@function .global _exit _exit: __exit: mov $__NR_exit, %al +.type __unified_syscall,@function __unified_syscall: movzbl %al, %eax 1: @@ -276,6 +278,16 @@ #include "../syscalls.s/capget.S" #include "../syscalls.s/capset.S" +#include "../syscalls.s/timer_create.S" +#include "../syscalls.s/timer_settime.S" +#include "../syscalls.s/timer_gettime.S" +#include "../syscalls.s/timer_getoverrun.S" +#include "../syscalls.s/timer_delete.S" + +#include "../syscalls.s/clock_settime.S" +#include "../syscalls.s/clock_gettime.S" +#include "../syscalls.s/clock_getres.S" + #undef __PIC__ #undef __socketcall /* oh what a kludge! */ diff -uNr dietlibc-0.25/i386/strcasecmp.S dietlibc-0.26/i386/strcasecmp.S --- dietlibc-0.25/i386/strcasecmp.S Sun Nov 3 01:14:35 2002 +++ dietlibc-0.26/i386/strcasecmp.S Thu Apr 29 17:23:13 2004 @@ -1,5 +1,6 @@ .text -.globl strcasecmp +.global strcasecmp +.type strcasecmp,@function strcasecmp: pushl %esi @@ -29,3 +30,5 @@ .Lfinifirst: subl %ecx, %eax jmp .Lret + +.size strcasecmp,.-strcasecmp diff -uNr dietlibc-0.25/i386/syscalls.h dietlibc-0.26/i386/syscalls.h --- dietlibc-0.25/i386/syscalls.h Fri Nov 7 15:24:39 2003 +++ dietlibc-0.26/i386/syscalls.h Thu Apr 29 17:23:13 2004 @@ -307,6 +307,7 @@ .type name,@function; \ .weak name; \ name: ; \ +.type __libc_##name,@function; \ .global __libc_##name; \ __libc_##name: ; \ movb $SYS_##NAME,%al; \ diff -uNr dietlibc-0.25/i386/vfork.S dietlibc-0.26/i386/vfork.S --- dietlibc-0.25/i386/vfork.S Sun Dec 22 02:08:51 2002 +++ dietlibc-0.26/i386/vfork.S Thu Apr 29 17:23:13 2004 @@ -1,5 +1,6 @@ .text -.globl vfork +.global vfork +.type vfork,@function vfork: popl %edx xorl %eax,%eax diff -uNr dietlibc-0.25/ia64/waitpid.S dietlibc-0.26/ia64/waitpid.S --- dietlibc-0.25/ia64/waitpid.S Fri Oct 10 15:37:34 2003 +++ dietlibc-0.26/ia64/waitpid.S Thu Jan 1 01:00:00 1970 @@ -1,11 +0,0 @@ -#include - - .text - .weak waitpid -waitpid: - .global __libc_waitpid -__libc_waitpid: - alloc r2=ar.pfs,4,0,0,0 - mov in3=r0 - mov r15=__NR_wait4 - br __unified_syscall diff -uNr dietlibc-0.25/include/grp.h dietlibc-0.26/include/grp.h --- dietlibc-0.25/include/grp.h Tue Aug 19 18:58:17 2003 +++ dietlibc-0.26/include/grp.h Thu Apr 15 12:31:18 2004 @@ -14,12 +14,12 @@ char **gr_mem; /* Member list. */ }; -extern struct group *getgrgid (gid_t uid) __THROW; -extern struct group *getgrnam (const char *name) __THROW; +struct group *getgrgid (gid_t uid) __THROW; +struct group *getgrnam (const char *name) __THROW; -extern struct group *getgrent(void) __THROW; -extern void setgrent(void) __THROW; -extern void endgrent(void) __THROW; +struct group *getgrent(void) __THROW; +void setgrent(void) __THROW; +void endgrent(void) __THROW; int getgrent_r(struct group *res, char *buf, size_t buflen, struct group **res_sig) __THROW; @@ -30,9 +30,10 @@ struct group *res, char *buf, size_t buflen, struct group **res_sig) __THROW; -extern int setgroups(size_t n, const gid_t *groups) __THROW; -extern int setgroups32(size_t n, const gid32_t *groups) __THROW; -extern int initgroups(const char *user, gid_t group) __THROW; +int setgroups(size_t n, const gid_t *groups) __THROW; +int setgroups32(size_t n, const gid32_t *groups) __THROW; +int initgroups(const char *user, gid_t group) __THROW; +int getgrouplist(const char*user,gid_t group,gid_t*groups,int*ngroups) __THROW; __END_DECLS diff -uNr dietlibc-0.25/include/netinet/in.h dietlibc-0.26/include/netinet/in.h --- dietlibc-0.25/include/netinet/in.h Wed Aug 27 13:32:36 2003 +++ dietlibc-0.26/include/netinet/in.h Thu Apr 15 12:31:18 2004 @@ -320,7 +320,7 @@ /* routing header type 0 (used in cmsghdr struct) */ -#ifndef __STRICT_ANSI__ +#if !defined(__STRICT_ANSI__) || (__STDC_VERSION__ + 0 >= 199900L) struct rt0_hdr { struct ipv6_rt_hdr rt_hdr; uint32_t bitmap; /* strict/loose bit map */ diff -uNr dietlibc-0.25/include/resolv.h dietlibc-0.26/include/resolv.h --- dietlibc-0.25/include/resolv.h Tue Aug 19 18:58:17 2003 +++ dietlibc-0.26/include/resolv.h Thu Jun 3 12:47:00 2004 @@ -123,6 +123,8 @@ unsigned char *comp_dn, unsigned char *exp_dn, int length) __THROW; +void res_close(void) __THROW __attribute_dontuse__; + __END_DECLS #endif diff -uNr dietlibc-0.25/include/signal.h dietlibc-0.26/include/signal.h --- dietlibc-0.25/include/signal.h Fri Nov 21 00:48:47 2003 +++ dietlibc-0.26/include/signal.h Mon May 17 19:51:36 2004 @@ -8,7 +8,6 @@ #define __WANT_POSIX1B_SIGNALS__ #include -#include #define NSIG 32 @@ -465,6 +464,36 @@ #define sa_handler _u._sa_handler #define sa_sigaction _u._sa_sigaction + +#define SIGEV_SIGNAL 0 /* notify via signal */ +#define SIGEV_NONE 1 /* other notification: meaningless */ +#define SIGEV_THREAD 2 /* deliver via thread creation */ +#define SIGEV_THREAD_ID 4 /* deliver to thread */ + +#define SIGEV_MAX_SIZE 64 +#ifndef SIGEV_PAD_SIZE +#define SIGEV_PAD_SIZE ((SIGEV_MAX_SIZE/sizeof(int)) - 3) +#endif + +typedef struct sigevent { + sigval_t sigev_value; + int sigev_signo; + int sigev_notify; + union { + int _pad[SIGEV_PAD_SIZE]; + int _tid; + + struct { + void(*_function)(sigval_t); + void*_attribute; /* really pthread_attr_t */ + } _sigev_thread; + } _sigev_un; +} sigevent_t; + +#define sigev_notify_function _sigev_un._sigev_thread._function +#define sigev_notify_attributes _sigev_un._sigev_thread._attribute +#define sigev_notify_thread_id _sigev_un._tid + typedef struct sigaltstack { #if defined(__mips__) void *ss_sp; @@ -496,6 +525,8 @@ int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact) __THROW; +#include + int sigtimedwait(const sigset_t *mask, siginfo_t *info, const struct timespec *ts) __THROW; int sigqueueinfo(int pid, int sig, siginfo_t *info) __THROW; int siginterrupt(int sig, int flag) __THROW; diff -uNr dietlibc-0.25/include/stdlib.h dietlibc-0.26/include/stdlib.h --- dietlibc-0.25/include/stdlib.h Wed Jan 7 16:06:48 2004 +++ dietlibc-0.26/include/stdlib.h Mon May 10 18:34:54 2004 @@ -17,7 +17,7 @@ char *getenv(const char *name) __THROW __pure; int putenv(const char *string) __THROW; int setenv(const char *name, const char *value, int overwrite) __THROW; -void unsetenv(const char *name) __THROW; +int unsetenv(const char *name) __THROW; int system (const char * string) __THROW; int atexit(void (*function)(void)) __THROW; diff -uNr dietlibc-0.25/include/sys/mount.h dietlibc-0.26/include/sys/mount.h --- dietlibc-0.25/include/sys/mount.h Tue Aug 19 18:58:18 2003 +++ dietlibc-0.26/include/sys/mount.h Wed May 12 17:54:52 2004 @@ -69,8 +69,10 @@ /* Possible value for FLAGS parameter of `umount2'. */ enum { - MNT_FORCE = 1 /* Force unmounting. */ + MNT_FORCE = 1, /* Force unmounting. */ #define MNT_FORCE MNT_FORCE + MNT_DETACH = 2 /* Just detach, unmount when last reference dies. */ +#define MNT_DETACH MNT_DETACH }; int mount(const char* specialfile, const char* dir, const char* filesystemtype, diff -uNr dietlibc-0.25/include/sys/select.h dietlibc-0.26/include/sys/select.h --- dietlibc-0.25/include/sys/select.h Tue Aug 19 18:58:18 2003 +++ dietlibc-0.26/include/sys/select.h Mon May 17 19:43:15 2004 @@ -2,6 +2,7 @@ #define _SYS_SELECT_H #include +#include __BEGIN_DECLS @@ -23,6 +24,11 @@ #define FD_ZERO(set) \ ((void) memset ((void*) (set), 0, sizeof (fd_set))) +int select(int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout) __THROW; + +int pselect(int n, fd_set* readfds, fd_set* writefds, fd_set* exceptfds, + const struct timespec *timeout, const sigset_t *sigmask) __THROW; + __END_DECLS #endif diff -uNr dietlibc-0.25/include/sys/time.h dietlibc-0.26/include/sys/time.h --- dietlibc-0.25/include/sys/time.h Tue Aug 19 18:58:18 2003 +++ dietlibc-0.26/include/sys/time.h Mon May 17 19:47:11 2004 @@ -3,7 +3,6 @@ #include #include -#include __BEGIN_DECLS @@ -22,6 +21,8 @@ int tz_dsttime; /* type of dst correction */ }; +#include + #define ITIMER_REAL 0 #define ITIMER_VIRTUAL 1 #define ITIMER_PROF 2 diff -uNr dietlibc-0.25/include/sys/types.h dietlibc-0.26/include/sys/types.h --- dietlibc-0.25/include/sys/types.h Wed Jan 7 16:06:48 2004 +++ dietlibc-0.26/include/sys/types.h Thu Apr 15 12:31:19 2004 @@ -108,12 +108,16 @@ typedef uint32_t uid32_t; typedef uint32_t gid32_t; +typedef int clockid_t; +typedef int timer_t; + typedef long int fpos_t; #define __socklen_t_defined typedef unsigned int socklen_t; typedef unsigned short sa_family_t; + #ifdef _BSD_SOURCE /* die, BSD, die! */ typedef char* caddr_t __attribute_dontuse__; @@ -133,8 +137,10 @@ typedef uint16_t nshort __attribute_dontuse__; /* never heard of these two, but dump uses them */ +#if !defined(__STRICT_ANSI__) || __STDC_VERSION__ + 0 >= 199900L typedef int64_t quad_t __attribute_dontuse__; typedef uint64_t u_quad_t __attribute_dontuse__; +#endif typedef long daddr_t __attribute_dontuse__; typedef daddr_t __daddr_t __attribute_dontuse__; diff -uNr dietlibc-0.25/include/time.h dietlibc-0.26/include/time.h --- dietlibc-0.25/include/time.h Fri Nov 21 00:48:47 2003 +++ dietlibc-0.26/include/time.h Mon May 10 18:34:54 2004 @@ -3,10 +3,30 @@ #include #include +#include __BEGIN_DECLS -extern int __isleap(int year); +int __isleap(int year); + +#define CLOCK_REALTIME 0 +#define CLOCK_MONOTONIC 1 +#define CLOCK_PROCESS_CPUTIME_ID 2 +#define CLOCK_THREAD_CPUTIME_ID 3 +#define CLOCK_REALTIME_HR 4 +#define CLOCK_MONOTONIC_HR 5 + +int clock_settime(clockid_t clock_id,const struct timespec*tp); +int clock_gettime(clockid_t clock_id,struct timespec*tp); +int clock_getres (clockid_t clock_id,struct timespec*res); + +#define TIMER_ABSTIME 1 + +int timer_create(clockid_t clock_id,struct sigevent*evp,timer_t*timerid) __THROW; +int timer_delete(timer_t timerid) __THROW; +int timer_settime(timer_t timerid,int flags,const struct itimerspec*ival,struct itimerspec*oval) __THROW; +int timer_gettime(timer_t timerid,const struct itimerspec*val) __THROW; +int timer_getoverrun(timer_t timerid) __THROW; int nanosleep(const struct timespec *req, struct timespec *rem) __THROW; diff -uNr dietlibc-0.25/include/unistd.h dietlibc-0.26/include/unistd.h --- dietlibc-0.25/include/unistd.h Mon Sep 22 19:48:56 2003 +++ dietlibc-0.26/include/unistd.h Mon May 17 19:46:36 2004 @@ -3,9 +3,9 @@ #include #include -#include #include #include +#include __BEGIN_DECLS @@ -56,8 +56,10 @@ int unlink(const char *pathname) __THROW; -int pread(int fd, void *buf, size_t count, off_t offset); -int pwrite(int fd, const void *buf, size_t count, off_t offset); +ssize_t pread(int fd, void *buf, size_t count, off_t offset); +ssize_t pwrite(int fd, const void *buf, size_t count, off_t offset); +ssize_t pread64(int fd, void *buf, size_t count, off64_t offset); +ssize_t pwrite64(int fd, const void *buf, size_t count, off64_t offset); int execve(const char *filename, char *const argv [], char *const envp[]) __THROW; int execlp(const char *file, const char *arg, ...) __THROW; @@ -148,8 +150,6 @@ int ftruncate64(int fd, loff_t length) __THROW; #endif -int select(int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout) __THROW; - int nice(int inc) __THROW; char *crypt(const char *key, const char *salt) __THROW; diff -uNr dietlibc-0.25/lib/.#__stat64_cvt.c.1.3 dietlibc-0.26/lib/.#__stat64_cvt.c.1.3 --- dietlibc-0.25/lib/.#__stat64_cvt.c.1.3 Thu Jan 1 01:00:00 1970 +++ dietlibc-0.26/lib/.#__stat64_cvt.c.1.3 Wed Mar 10 15:23:20 2004 @@ -0,0 +1,21 @@ +#include +#ifndef __NO_STAT64 + +void __stat64_cvt(const struct stat *src,struct stat64 *dest); + +void __stat64_cvt(const struct stat *src,struct stat64 *dest) { + dest->st_dev=src->st_dev; + dest->st_ino=src->st_ino; + dest->st_mode=src->st_mode; + dest->st_nlink=src->st_nlink; + dest->st_uid=src->st_uid; + dest->st_gid=src->st_gid; + dest->st_rdev=src->st_rdev; + dest->st_size=src->st_size; + dest->st_blksize=src->st_blksize; + dest->st_blocks=src->st_blocks; + dest->st_atime=src->st_atime; + dest->st_mtime=src->st_mtime; + dest->st_ctime=src->st_ctime; +} +#endif diff -uNr dietlibc-0.25/lib/alloc.c dietlibc-0.26/lib/alloc.c --- dietlibc-0.25/lib/alloc.c Tue Jan 27 15:24:11 2004 +++ dietlibc-0.26/lib/alloc.c Wed Apr 21 14:04:20 2004 @@ -44,14 +44,7 @@ /* a simple mmap :) */ -#ifdef __i386__ -/* regparm exists only on i386 */ -static void *do_mmap(size_t size) __attribute__((regparm(1))); -static size_t get_index(size_t _size) __attribute__((regparm(1))); -static void* __small_malloc(size_t _size) __attribute__((regparm(1))); -#endif - -static void *do_mmap(size_t size) { +static void __attribute__((regparm(1))) *do_mmap(size_t size) { return mmap(0, size, PROT_READ|PROT_WRITE, MAP_ANONYMOUS|MAP_PRIVATE, -1, (size_t)0); } @@ -70,7 +63,7 @@ static inline int __ind_shift() { return (MEM_BLOCK_SIZE==4096)?4:5; } -static size_t get_index(size_t _size) { +static size_t __attribute__((regparm(1))) get_index(size_t _size) { register size_t idx=0; if (_size) { register size_t size=((_size-1)&(MEM_BLOCK_SIZE-1))>>__ind_shift(); @@ -82,7 +75,7 @@ /* small mem */ static void __small_free(void*_ptr,size_t _size) __attribute__((regparm(2))); -static void __small_free(void*_ptr,size_t _size) { +static void __attribute__((regparm(2))) __small_free(void*_ptr,size_t _size) { __alloc_t* ptr=BLOCK_START(_ptr); size_t size=_size; size_t idx=get_index(size); @@ -93,7 +86,7 @@ __small_mem[idx]=ptr; } -static void* __small_malloc(size_t _size) { +static void* __attribute__((regparm(1))) __small_malloc(size_t _size) { __alloc_t *ptr; size_t size=_size; size_t idx; diff -uNr dietlibc-0.25/lib/pread.c dietlibc-0.26/lib/pread.c --- dietlibc-0.25/lib/pread.c Tue Aug 14 18:56:50 2001 +++ dietlibc-0.26/lib/pread.c Mon May 10 22:58:22 2004 @@ -1,11 +1,10 @@ #include #include +#include -extern size_t __pread(int fd, void *buf, size_t count, off_t a,off_t b); - -size_t __libc_pread(int fd, void *buf, size_t count, off_t offset); -size_t __libc_pread(int fd, void *buf, size_t count, off_t offset) { - return __pread(fd,buf,count,offset,0); +ssize_t __libc_pread(int fd, void *buf, size_t count, off_t offset); +ssize_t __libc_pread(int fd, void *buf, size_t count, off_t offset) { + return pread64(fd,buf,count,offset); } -int pread(int fd, void *buf, size_t count, off_t offset) __attribute__((weak,alias("__libc_pread"))); +ssize_t pread(int fd, void *buf, size_t count, off_t offset) __attribute__((weak,alias("__libc_pread"))); diff -uNr dietlibc-0.25/lib/pread64.c dietlibc-0.26/lib/pread64.c --- dietlibc-0.25/lib/pread64.c Fri Oct 5 02:26:12 2001 +++ dietlibc-0.26/lib/pread64.c Thu Jan 1 01:00:00 1970 @@ -1,14 +0,0 @@ -#include -#include -#include - -#ifndef __NO_STAT64 -extern size_t __pread(int fd, void *buf, size_t count, off_t a,off_t b); - -size_t __libc_pread64(int fd, void *buf, size_t count, off64_t offset); -size_t __libc_pread64(int fd, void *buf, size_t count, off64_t offset) { - return __pread(fd,buf,count,__LONG_LONG_PAIR ((off_t)(offset&0xffffffff),(off_t)(offset>>32))); -} - -int pread64(int fd, void *buf, size_t count, off_t offset) __attribute__((weak,alias("__libc_pread64"))); -#endif diff -uNr dietlibc-0.25/lib/pselect.c dietlibc-0.26/lib/pselect.c --- dietlibc-0.25/lib/pselect.c Thu Jan 1 01:00:00 1970 +++ dietlibc-0.26/lib/pselect.c Mon May 17 19:44:11 2004 @@ -0,0 +1,20 @@ +#include + +int pselect(int n, fd_set* readfds, fd_set* writefds, fd_set* exceptfds, + const struct timespec *timeout, const sigset_t *sigmask) { + struct timeval t; + sigset_t old; + int r; + if (timeout) { + t.tv_sec=timeout->tv_sec; + t.tv_usec=timeout->tv_nsec/1000; + if (!t.tv_sec && !t.tv_usec && timeout->tv_nsec) ++t.tv_usec; + } + if (sigmask) + sigprocmask(SIG_SETMASK,sigmask,&old); + r=select(n,readfds,writefds,exceptfds, + timeout?&t:0); + if (sigmask) + sigprocmask(SIG_SETMASK,&old,0); + return r; +} diff -uNr dietlibc-0.25/lib/pwrite.c dietlibc-0.26/lib/pwrite.c --- dietlibc-0.25/lib/pwrite.c Tue Oct 2 21:19:46 2001 +++ dietlibc-0.26/lib/pwrite.c Mon May 10 22:55:37 2004 @@ -1,11 +1,10 @@ #include #include - -extern size_t __pwrite(int fd, void *buf, size_t count, off_t a,off_t b); +#include size_t __libc_pwrite(int fd, void *buf, size_t count, off_t offset); size_t __libc_pwrite(int fd, void *buf, size_t count, off_t offset) { - return __pwrite(fd,buf,count,offset,0); + return pwrite64(fd,buf,count,offset); } -int pwrite(int fd, void *buf, size_t count, off_t offset) __attribute__((weak,alias("__libc_pwrite"))); +ssize_t pwrite(int fd, const void *buf, size_t count, off_t offset) __attribute__((weak,alias("__libc_pwrite"))); diff -uNr dietlibc-0.25/lib/pwrite64.c dietlibc-0.26/lib/pwrite64.c --- dietlibc-0.25/lib/pwrite64.c Fri Oct 5 02:26:12 2001 +++ dietlibc-0.26/lib/pwrite64.c Thu Jan 1 01:00:00 1970 @@ -1,14 +0,0 @@ -#include -#include -#include - -#ifndef __NO_STAT64 -extern size_t __pwrite(int fd, void *buf, size_t count, off_t a,off_t b); - -size_t __libc_pwrite64(int fd, void *buf, size_t count, off64_t offset); -size_t __libc_pwrite64(int fd, void *buf, size_t count, off64_t offset) { - return __pwrite(fd,buf,count,__LONG_LONG_PAIR ((off_t)(offset&0xffffffff),(off_t)(offset>>32))); -} - -int pwrite64(int fd, void *buf, size_t count, off_t offset) __attribute__((weak,alias("__libc_pwrite64"))); -#endif diff -uNr dietlibc-0.25/lib/qsort.c dietlibc-0.26/lib/qsort.c --- dietlibc-0.25/lib/qsort.c Sun Nov 2 01:47:37 2003 +++ dietlibc-0.26/lib/qsort.c Thu Jun 3 13:34:36 2004 @@ -43,7 +43,7 @@ tmp+=size; } iswap(min,base,size); - (char*)base+=size; + base=(void*)((char*)base+size); nmemb-=1; } } diff -uNr dietlibc-0.25/lib/write12.c dietlibc-0.26/lib/write12.c --- dietlibc-0.25/lib/write12.c Sat Feb 23 23:18:42 2002 +++ dietlibc-0.26/lib/write12.c Thu May 6 16:46:43 2004 @@ -2,10 +2,10 @@ #include #include -int __write1 (const char* s) { +int __attribute__ (( regparm(1) )) __write1 (const char* s) { return write(1, s, strlen(s)); } -int __write2 (const char* s) { +int __attribute__ (( regparm(1) )) __write2 (const char* s) { return write(2, s, strlen(s)); } diff -uNr dietlibc-0.25/libcruft/initgroups.c dietlibc-0.26/libcruft/initgroups.c --- dietlibc-0.25/libcruft/initgroups.c Thu Jun 7 14:29:36 2001 +++ dietlibc-0.26/libcruft/initgroups.c Thu Apr 15 12:31:21 2004 @@ -1,24 +1,41 @@ #include #include #include +#include + +static int _getgrouplist(const char*user,gid_t group,gid_t*groups,int*ngroups) { + long n=0,size=*ngroups; + struct group*g; + int ret=0; + + if (__likely(ngr_mem; while (*duh) { if (!strcmp(*duh,user)) { - grouplist[n]=g->gr_gid; - if (++n>=32) - break; + if (__unlikely(++n>=NGROUPS_MAX)) { + ret=~ret; + goto err_out; + } + if (__likely(ngr_gid; } duh++; } } +err_out: + endgrent(); + *ngroups=n; + return ret; +} +int getgrouplist(const char*user,gid_t group,gid_t*groups,int*ngroups) +__attribute__((alias("_getgrouplist"))); + +int initgroups(const char*user,gid_t group) { + int n=NGROUPS_MAX; + gid_t grouplist[NGROUPS_MAX]; + _getgrouplist(user,group,grouplist,&n); return setgroups(n,grouplist); } diff -uNr dietlibc-0.25/libcruft/res_close.c dietlibc-0.26/libcruft/res_close.c --- dietlibc-0.25/libcruft/res_close.c Thu Jan 1 01:00:00 1970 +++ dietlibc-0.26/libcruft/res_close.c Thu Jun 3 12:47:36 2004 @@ -0,0 +1,15 @@ +#include +#include +#include "dietfeatures.h" + +extern int __dns_fd; +#ifdef WANT_IPV6_DNS +extern int __dns_fd6; +#endif + +void res_close(void) { + if (__dns_fd!=-1) { close(__dns_fd); __dns_fd=-1; } +#ifdef WANT_IPV6_DNS + if (__dns_fd6!=-1) { close(__dns_fd6); __dns_fd6=-1; } +#endif +} diff -uNr dietlibc-0.25/libpthread/pthread_internal.c dietlibc-0.26/libpthread/pthread_internal.c --- dietlibc-0.25/libpthread/pthread_internal.c Mon Sep 29 16:00:59 2003 +++ dietlibc-0.26/libpthread/pthread_internal.c Wed Apr 21 14:11:46 2004 @@ -49,10 +49,7 @@ static inline unsigned long hash_tid(int tid) { return (tid&(NR_BUCKETS-1)); } /* O(1) */ -#if defined(__i386__) -static void __thread_add_tid_(_pthread_descr*root,_pthread_descr thread) __attribute__((regparm(2))); -#endif -static void __thread_add_tid_(_pthread_descr*root,_pthread_descr thread) { +static void __attribute__((regparm(2))) __thread_add_tid_(_pthread_descr*root,_pthread_descr thread) { _pthread_descr tmp=*root; thread->prev=root; thread->next=tmp; @@ -78,10 +75,12 @@ #if defined(__i386__) static _pthread_descr __thread_find_(int pid) __attribute__((regparm(1))); _pthread_descr __thread_find(int pid) { return __thread_find_(pid); } +static _pthread_descr __attribute__((regparm(1))) __thread_find_(int pid) #else _pthread_descr __thread_find(int pid) __attribute__((alias("__thread_find_"))); +static _pthread_descr __thread_find_(int pid) #endif -static _pthread_descr __thread_find_(int pid) { +{ _pthread_descr cur; if (__thread_started==PTHREAD_ONCE_INIT) { /* uninitialised */ LOCK(&_main_thread); diff -uNr dietlibc-0.25/libshell/realpath.c dietlibc-0.26/libshell/realpath.c --- dietlibc-0.25/libshell/realpath.c Tue Jan 27 22:50:42 2004 +++ dietlibc-0.26/libshell/realpath.c Mon May 10 18:23:11 2004 @@ -1,14 +1,3 @@ -/* realpath - determine the absolute pathname of a file - - Copyright (C) 2003 Thomas M. Ogrisegg - - This realpath has still space for improvements: - e.g., if the initial path does not start with '/' it should - be checked whether the first path component(s) is/are symlinks. - This would save lots of filesystem lookups, but also greatly - increases complexity. -*/ - #include #include #include @@ -16,75 +5,44 @@ #include #include #include +#include -#define CD(x) (x=='/'||!x) - -char * -realpath (const char *file, char *dst) -{ - unsigned char buffer[PATH_MAX]; - size_t i, off; - - if (!file || !dst) { errno = EINVAL; return (NULL); } - if (!*file) { errno = ENOENT; return (NULL); } - - if (*file != '/') { - if (!getcwd (buffer, sizeof (buffer))) return (NULL); - off = strlen (buffer); - while (file[0] == '.' && file[1] == '.' && file[2] == '/') { - if (off) off--; - while (off && buffer[off] != '/') off--; - file += 3; - } - buffer[off++] = '/'; - i = strlen (file); - if (i+off >= PATH_MAX) return (NULL); - memcpy (buffer+off, file, i+1); - file = buffer; +static char* myrealpath(const char* file, char* dest, int count) { +/* assume dest has PATH_MAX space */ + char buf[PATH_MAX+1]; + char* c; + int i; + + if (count<0) { errno=EMLINK; return 0; } + if (chdir(file)==0) + /* hurray! The easy case: it's a directory! */ + return getcwd(dest,PATH_MAX); + + c=strrchr(file,'/'); + if (c) { + if (c-file>PATH_MAX) return 0; + memcpy(buf,file,c-file); + buf[c-file]=0; + if (chdir(buf)==-1) return 0; + file=c+1; } - - off = i = 0; - - while (file[i]) { - if (file[i] == '.' && file[i-1] == '/' && - ((file[i+1] == '.'&&CD(file[i+2])) || CD(file[i+1]))) { - if (file[i+1] == '/') { i+=2; continue; } - if (file[i+1] == '.') { - if (off > 2) off -= 2; - while (off && dst[off] != '/') off--; - i++; - } - i++; - continue; - } - - if (file[i] == '/' && off < PATH_MAX) { - unsigned char buf[PATH_MAX]; - int ret; - - if (file[i+1] == '/') { i+=2; continue; } - - if (off) { - if (dst[off-1] == '/') { i++; continue; } - -last_test: - dst[off] = 0; - if (-1 != (ret = readlink (dst, buf, sizeof (buf)))) { - struct stat st; - buf[ret] = 0; - if (-1 == stat (buf, &st)) return (NULL); - if (ret+(PATH_MAX-i) > PATH_MAX) return (NULL); - strcpy (buf+ret, file+i); - return (realpath (buf, dst)); - } else - if (errno == EACCES || errno == ENOENT) return (NULL); - - if (!file[i]) return (dst); - } - } - dst[off++] = file[i++]; + if (readlink(file,buf,PATH_MAX)==0) + return myrealpath(buf,dest,count-1); + if (getcwd(dest,PATH_MAX)==0) return 0; + i=strlen(dest); dest[i]='/'; ++i; + for (; i 2 && dst[off-1] == '/') off--; - goto last_test; +char* realpath(const char* file, char* dest) { + int fd=open(".",O_RDONLY); /* save directory */ + char* res=myrealpath(file,dest,31); + fchdir(fd); + close(fd); + return res; } + diff -uNr dietlibc-0.25/libstdio/fwrite.c dietlibc-0.26/libstdio/fwrite.c --- dietlibc-0.25/libstdio/fwrite.c Fri Nov 14 15:52:16 2003 +++ dietlibc-0.26/libstdio/fwrite.c Thu Apr 15 12:31:22 2004 @@ -15,7 +15,7 @@ if (len>stream->buflen || (stream->flags&NOBUF)) { if (fflush_unlocked(stream)) return 0; do { - res=__libc_write(stream->fd,ptr,size*nmemb); + res=__libc_write(stream->fd,ptr,len); } while (res==-1 && errno==EINTR); } else { register const unsigned char *c=ptr; diff -uNr dietlibc-0.25/libugly/iconv.c dietlibc-0.26/libugly/iconv.c --- dietlibc-0.25/libugly/iconv.c Mon Dec 1 18:42:12 2003 +++ dietlibc-0.26/libugly/iconv.c Thu Apr 15 12:31:22 2004 @@ -109,11 +109,11 @@ j=4; break; case UTF_8: - if (v>0x04000000) { bits=30; *out=0xFC; j=6; } else - if (v>0x00200000) { bits=24; *out=0xF8; j=5; } else - if (v>0x00010000) { bits=18; *out=0xF0; j=4; } else - if (v>0x00000800) { bits=12; *out=0xE0; j=3; } else - if (v>0x00000080) { bits=6; *out=0xC0; j=2; } else + if (v>=0x04000000) { bits=30; *out=0xFC; j=6; } else + if (v>=0x00200000) { bits=24; *out=0xF8; j=5; } else + if (v>=0x00010000) { bits=18; *out=0xF0; j=4; } else + if (v>=0x00000800) { bits=12; *out=0xE0; j=3; } else + if (v>=0x00000080) { bits=6; *out=0xC0; j=2; } else { bits=0; *out=0; } *out|= (unsigned char)(v>>bits); if (*outbytesleft t) { -// printf("FOUND!1!! Offset %d\n",prevtz); - return t-prevtz; +// printf("FOUND!1!! Offset %d\n",nexttz); + return t-nexttz; } lastval=k; } diff -uNr dietlibc-0.25/libugly/unsetenv.c dietlibc-0.26/libugly/unsetenv.c --- dietlibc-0.25/libugly/unsetenv.c Fri Mar 16 21:09:19 2001 +++ dietlibc-0.26/libugly/unsetenv.c Thu Apr 15 12:31:22 2004 @@ -1,6 +1,6 @@ #include -void unsetenv(const char *name) { - putenv(name); +int unsetenv(const char *name) { + return putenv(name); } diff -uNr dietlibc-0.25/mips/Makefile.add dietlibc-0.26/mips/Makefile.add --- dietlibc-0.25/mips/Makefile.add Wed Jun 18 17:20:00 2003 +++ dietlibc-0.26/mips/Makefile.add Tue May 11 15:33:54 2004 @@ -11,3 +11,4 @@ endif CFLAGS+=$(ENDIAN) -Os -G 0 -fstrict-aliasing -fno-pic -mno-abicalls VPATH:=mips:syscalls.s:$(VPATH) +LIBOBJ+=$(OBJDIR)/pread64.o $(OBJDIR)/pwrite64.o diff -uNr dietlibc-0.25/mips/__pread.S dietlibc-0.26/mips/__pread.S --- dietlibc-0.25/mips/__pread.S Thu Jan 1 01:00:00 1970 +++ dietlibc-0.26/mips/__pread.S Tue May 11 15:33:53 2004 @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(pread,__pread) diff -uNr dietlibc-0.25/mips/__pwrite.S dietlibc-0.26/mips/__pwrite.S --- dietlibc-0.25/mips/__pwrite.S Thu Jan 1 01:00:00 1970 +++ dietlibc-0.26/mips/__pwrite.S Tue May 11 15:33:53 2004 @@ -0,0 +1,3 @@ +#include "syscalls.h" + +syscall(pwrite,__pwrite) diff -uNr dietlibc-0.25/mips/pread.c dietlibc-0.26/mips/pread.c --- dietlibc-0.25/mips/pread.c Thu Jan 1 01:00:00 1970 +++ dietlibc-0.26/mips/pread.c Mon May 10 22:34:12 2004 @@ -0,0 +1,11 @@ +#include +#include + +extern size_t __pread(int fd, void *buf, size_t count, int dummy, off_t a, off_t b); + +size_t __libc_pread(int fd, void *buf, size_t count, off_t offset); +size_t __libc_pread(int fd, void *buf, size_t count, off_t offset) { + return __pread(fd,buf,count,0,__LONG_LONG_PAIR(0,offset)); +} + +int pread(int fd, void *buf, size_t count, off_t offset) __attribute__((weak,alias("__libc_pread"))); diff -uNr dietlibc-0.25/mips/pread64.c dietlibc-0.26/mips/pread64.c --- dietlibc-0.25/mips/pread64.c Thu Jan 1 01:00:00 1970 +++ dietlibc-0.26/mips/pread64.c Mon May 10 22:34:12 2004 @@ -0,0 +1,14 @@ +#include +#include +#include + +#ifndef __NO_STAT64 +extern size_t __pread(int fd, void *buf, size_t count, int dummy, off_t a, off_t b); + +size_t __libc_pread64(int fd, void *buf, size_t count, off64_t offset); +size_t __libc_pread64(int fd, void *buf, size_t count, off64_t offset) { + return __pread(fd,buf,count,0,__LONG_LONG_PAIR( (off_t)(offset>>32),(off_t)(offset&0xffffffff) )); +} + +int pread64(int fd, void *buf, size_t count, off_t offset) __attribute__((weak,alias("__libc_pread64"))); +#endif diff -uNr dietlibc-0.25/mips/pwrite.c dietlibc-0.26/mips/pwrite.c --- dietlibc-0.25/mips/pwrite.c Thu Jan 1 01:00:00 1970 +++ dietlibc-0.26/mips/pwrite.c Mon May 10 22:34:12 2004 @@ -0,0 +1,11 @@ +#include +#include + +extern size_t __pwrite(int fd, void *buf, size_t count, int dummy, off_t a, off_t b); + +size_t __libc_pwrite(int fd, void *buf, size_t count, off_t offset); +size_t __libc_pwrite(int fd, void *buf, size_t count, off_t offset) { + return __pwrite(fd,buf,count,0,__LONG_LONG_PAIR(0,offset)); +} + +int pwrite(int fd, void *buf, size_t count, off_t offset) __attribute__((weak,alias("__libc_pwrite"))); diff -uNr dietlibc-0.25/mips/pwrite64.c dietlibc-0.26/mips/pwrite64.c --- dietlibc-0.25/mips/pwrite64.c Thu Jan 1 01:00:00 1970 +++ dietlibc-0.26/mips/pwrite64.c Mon May 10 22:34:12 2004 @@ -0,0 +1,14 @@ +#include +#include +#include + +#ifndef __NO_STAT64 +extern size_t __pwrite(int fd, void *buf, size_t count, int dummy, off_t a, off_t b); + +size_t __libc_pwrite64(int fd, void *buf, size_t count, off64_t offset); +size_t __libc_pwrite64(int fd, void *buf, size_t count, off64_t offset) { + return __pwrite(fd,buf,count,0,__LONG_LONG_PAIR ((off_t)(offset>>32),(off_t)(offset&0xffffffff))); +} + +int pwrite64(int fd, void *buf, size_t count, off_t offset) __attribute__((weak,alias("__libc_pwrite64"))); +#endif diff -uNr dietlibc-0.25/syscalls.s/__pread.S dietlibc-0.26/syscalls.s/__pread.S --- dietlibc-0.25/syscalls.s/__pread.S Tue Oct 2 21:21:12 2001 +++ dietlibc-0.26/syscalls.s/__pread.S Mon May 10 22:52:18 2004 @@ -1,3 +1,3 @@ #include "syscalls.h" -syscall(pread,__pread) +syscall_weak(pread,pread64,__libc_pread64) diff -uNr dietlibc-0.25/syscalls.s/__pwrite.S dietlibc-0.26/syscalls.s/__pwrite.S --- dietlibc-0.25/syscalls.s/__pwrite.S Tue Oct 2 21:21:12 2001 +++ dietlibc-0.26/syscalls.s/__pwrite.S Mon May 10 22:52:36 2004 @@ -1,3 +1,3 @@ #include "syscalls.h" -syscall(pwrite,__pwrite) +syscall_weak(pwrite,pwrite64,__libc_pwrite64) diff -uNr dietlibc-0.25/syscalls.s/_llseek.S dietlibc-0.26/syscalls.s/_llseek.S --- dietlibc-0.25/syscalls.s/_llseek.S Mon Nov 12 15:47:01 2001 +++ dietlibc-0.26/syscalls.s/_llseek.S Thu Apr 29 17:23:14 2004 @@ -2,6 +2,7 @@ #ifdef __NR__llseek .global llseek +.type llseek,function llseek: syscall(_llseek,_llseek) #endif diff -uNr dietlibc-0.25/syscalls.s/clock_getres.S dietlibc-0.26/syscalls.s/clock_getres.S --- dietlibc-0.25/syscalls.s/clock_getres.S Thu Jan 1 01:00:00 1970 +++ dietlibc-0.26/syscalls.s/clock_getres.S Wed Apr 14 15:13:29 2004 @@ -0,0 +1,5 @@ +#include "syscalls.h" + +#ifdef __NR_clock_getres +syscall(clock_getres,clock_getres) +#endif diff -uNr dietlibc-0.25/syscalls.s/clock_gettime.S dietlibc-0.26/syscalls.s/clock_gettime.S --- dietlibc-0.25/syscalls.s/clock_gettime.S Thu Jan 1 01:00:00 1970 +++ dietlibc-0.26/syscalls.s/clock_gettime.S Wed Apr 14 15:13:29 2004 @@ -0,0 +1,5 @@ +#include "syscalls.h" + +#ifdef __NR_clock_gettime +syscall(clock_gettime,clock_gettime) +#endif diff -uNr dietlibc-0.25/syscalls.s/clock_settime.S dietlibc-0.26/syscalls.s/clock_settime.S --- dietlibc-0.25/syscalls.s/clock_settime.S Thu Jan 1 01:00:00 1970 +++ dietlibc-0.26/syscalls.s/clock_settime.S Wed Apr 14 15:13:29 2004 @@ -0,0 +1,5 @@ +#include "syscalls.h" + +#ifdef __NR_clock_settime +syscall(clock_settime,clock_settime) +#endif diff -uNr dietlibc-0.25/syscalls.s/timer_create.S dietlibc-0.26/syscalls.s/timer_create.S --- dietlibc-0.25/syscalls.s/timer_create.S Thu Jan 1 01:00:00 1970 +++ dietlibc-0.26/syscalls.s/timer_create.S Wed Apr 14 15:13:29 2004 @@ -0,0 +1,5 @@ +#include "syscalls.h" + +#ifdef __NR_timer_create +syscall(timer_create,timer_create) +#endif diff -uNr dietlibc-0.25/syscalls.s/timer_delete.S dietlibc-0.26/syscalls.s/timer_delete.S --- dietlibc-0.25/syscalls.s/timer_delete.S Thu Jan 1 01:00:00 1970 +++ dietlibc-0.26/syscalls.s/timer_delete.S Wed Apr 14 15:13:29 2004 @@ -0,0 +1,5 @@ +#include "syscalls.h" + +#ifdef __NR_timer_delete +syscall(timer_delete,timer_delete) +#endif diff -uNr dietlibc-0.25/syscalls.s/timer_getoverrun.S dietlibc-0.26/syscalls.s/timer_getoverrun.S --- dietlibc-0.25/syscalls.s/timer_getoverrun.S Thu Jan 1 01:00:00 1970 +++ dietlibc-0.26/syscalls.s/timer_getoverrun.S Wed Apr 14 15:13:29 2004 @@ -0,0 +1,5 @@ +#include "syscalls.h" + +#ifdef __NR_timer_getoverrun +syscall(timer_getoverrun,timer_getoverrun) +#endif diff -uNr dietlibc-0.25/syscalls.s/timer_gettime.S dietlibc-0.26/syscalls.s/timer_gettime.S --- dietlibc-0.25/syscalls.s/timer_gettime.S Thu Jan 1 01:00:00 1970 +++ dietlibc-0.26/syscalls.s/timer_gettime.S Wed Apr 14 15:13:29 2004 @@ -0,0 +1,5 @@ +#include "syscalls.h" + +#ifdef __NR_timer_gettime +syscall(timer_gettime,timer_gettime) +#endif diff -uNr dietlibc-0.25/syscalls.s/timer_settime.S dietlibc-0.26/syscalls.s/timer_settime.S --- dietlibc-0.25/syscalls.s/timer_settime.S Thu Jan 1 01:00:00 1970 +++ dietlibc-0.26/syscalls.s/timer_settime.S Wed Apr 14 15:13:29 2004 @@ -0,0 +1,5 @@ +#include "syscalls.h" + +#ifdef __NR_timer_settime +syscall(timer_settime,timer_settime) +#endif diff -uNr dietlibc-0.25/t1.c dietlibc-0.26/t1.c --- dietlibc-0.25/t1.c Thu Jan 1 01:00:00 1970 +++ dietlibc-0.26/t1.c Fri Dec 5 19:47:15 2003 @@ -0,0 +1,5 @@ +#include + +main() { + printf("%2.5g\n",-0.0); +} diff -uNr dietlibc-0.25/t2.c dietlibc-0.26/t2.c --- dietlibc-0.25/t2.c Thu Jan 1 01:00:00 1970 +++ dietlibc-0.26/t2.c Mon May 10 18:38:50 2004 @@ -0,0 +1,7 @@ +#include +#include + +main() { + char* c=alloca(1234); + strcpy(c,"fnord"); +} diff -uNr dietlibc-0.25/test/execlp.c dietlibc-0.26/test/execlp.c --- dietlibc-0.25/test/execlp.c Thu Jan 1 01:00:00 1970 +++ dietlibc-0.26/test/execlp.c Sat Mar 6 23:30:51 2004 @@ -0,0 +1,5 @@ +#include + +main() { + execlp("gcc","-v",0); +} diff -uNr dietlibc-0.25/threadsafe.sh dietlibc-0.26/threadsafe.sh --- dietlibc-0.25/threadsafe.sh Thu May 17 01:41:36 2001 +++ dietlibc-0.26/threadsafe.sh Mon May 10 14:41:23 2004 @@ -1,5 +1,5 @@ #!/bin/sh -(gcc -E - << EOF | grep -q WANT_THREAD_SAFE) || echo libpthread/pthread_*.c +(gcc -E - << EOF | grep WANT_THREAD_SAFE > /dev/null) || echo libpthread/pthread_*.c #include "dietfeatures.h" WANT_THREAD_SAFE EOF