1 diff -urN -x CVS dietlibc-0.31/alpha/strlen.c dietlibc/alpha/strlen.c
2 --- dietlibc-0.31/alpha/strlen.c 2001-01-09 18:57:38.000000000 +0100
3 +++ dietlibc/alpha/strlen.c 1970-01-01 01:00:00.000000000 +0100
7 -static const unsigned long long magic = 0x0101010101010101LL;
9 -size_t strlen(const char *s)
12 - unsigned long long word;
16 - /* Byte compare up until 64 bit word boundary */
17 - for (; ((unsigned long long) t & 7); t++)
18 - if (!*t) return t - s;
22 - word = *((unsigned long long *) t); t += 8;
23 - word = (word - magic) &~ word;
24 - word &= (magic << 7);
25 - } while (word == 0);
27 - /* word & 0x8080808080808080 == word */
28 - word = (word - 1) & (magic << 8);
29 - word += (word << 32);
30 - word += (word << 16);
31 - word += (word << 8);
33 - return ((const char *) t) - 8 - s;
37 diff -urN -x CVS dietlibc-0.31/alpha/syscalls.h dietlibc/alpha/syscalls.h
38 --- dietlibc-0.31/alpha/syscalls.h 2005-09-21 09:33:08.000000000 +0200
39 +++ dietlibc/alpha/syscalls.h 2008-02-19 01:28:13.000000000 +0100
41 #define __NR_inotify_init 444
42 #define __NR_inotify_add_watch 445
43 #define __NR_inotify_rm_watch 446
44 +#define __NR_fdatasync 447
45 +#define __NR_kexec_load 448
46 +#define __NR_migrate_pages 449
47 +#define __NR_openat 450
48 +#define __NR_mkdirat 451
49 +#define __NR_mknodat 452
50 +#define __NR_fchownat 453
51 +#define __NR_futimesat 454
52 +#define __NR_fstatat64 455
53 +#define __NR_unlinkat 456
54 +#define __NR_renameat 457
55 +#define __NR_linkat 458
56 +#define __NR_symlinkat 459
57 +#define __NR_readlinkat 460
58 +#define __NR_fchmodat 461
59 +#define __NR_faccessat 462
60 +#define __NR_pselect6 463
61 +#define __NR_ppoll 464
62 +#define __NR_unshare 465
63 +#define __NR_set_robust_list 466
64 +#define __NR_get_robust_list 467
65 +#define __NR_splice 468
66 +#define __NR_sync_file_range 469
68 +#define __NR_vmsplice 471
69 +#define __NR_move_pages 472
70 +#define __NR_getcpu 473
71 +#define __NR_epoll_pwait 474
72 +#define __NR_utimensat 475
73 +#define __NR_signalfd 476
74 +#define __NR_timerfd 477
75 +#define __NR_eventfd 478
78 #define syscall_weak(name,wsym,sym) \
79 diff -urN -x CVS dietlibc-0.31/arm/accept.S dietlibc/arm/accept.S
80 --- dietlibc-0.31/arm/accept.S 1970-01-01 01:00:00.000000000 +0100
81 +++ dietlibc/arm/accept.S 2008-09-05 17:13:29.000000000 +0200
85 +#include "syscalls.h"
87 +syscall(accept,accept)
90 diff -urN -x CVS dietlibc-0.31/arm/__aeabi_unwind_cpp.S dietlibc/arm/__aeabi_unwind_cpp.S
91 --- dietlibc-0.31/arm/__aeabi_unwind_cpp.S 1970-01-01 01:00:00.000000000 +0100
92 +++ dietlibc/arm/__aeabi_unwind_cpp.S 2008-04-12 00:51:11.000000000 +0200
95 +.global __aeabi_unwind_cpp_pr0
96 +.hidden __aeabi_unwind_cpp_pr0
97 +.type __aeabi_unwind_cpp_pr0, %function
99 +.global __aeabi_unwind_cpp_pr1
100 +.hidden __aeabi_unwind_cpp_pr1
101 +.type __aeabi_unwind_cpp_pr1, %function
103 +.global __aeabi_unwind_cpp_pr2
104 +.hidden __aeabi_unwind_cpp_pr2
105 +.type __aeabi_unwind_cpp_pr2, %function
107 +__aeabi_unwind_cpp_pr0:
108 +__aeabi_unwind_cpp_pr1:
109 +__aeabi_unwind_cpp_pr2:
110 + mov pc, lr @ return from subroutine
112 +.size __aeabi_unwind_cpp_pr0,.-__aeabi_unwind_cpp_pr0
113 +.size __aeabi_unwind_cpp_pr1,.-__aeabi_unwind_cpp_pr1
114 +.size __aeabi_unwind_cpp_pr2,.-__aeabi_unwind_cpp_pr2
115 diff -urN -x CVS dietlibc-0.31/arm/bind.S dietlibc/arm/bind.S
116 --- dietlibc-0.31/arm/bind.S 1970-01-01 01:00:00.000000000 +0100
117 +++ dietlibc/arm/bind.S 2008-09-05 17:13:29.000000000 +0200
121 +#include "syscalls.h"
126 diff -urN -x CVS dietlibc-0.31/arm/clone.S dietlibc/arm/clone.S
127 --- dietlibc-0.31/arm/clone.S 2002-02-28 17:27:02.000000000 +0100
128 +++ dietlibc/arm/clone.S 2008-09-05 17:13:29.000000000 +0200
130 @ Some slightly tricky stuff here... edit with care :-)
136 +#define CLONE_VM 0x00000100
137 +#define CLONE_THREAD 0x00010000
139 +@ ; don't do this yet
145 + @ ; start with a sanity check
149 + beq __unified_syscall @ handle as if error was returned by the syscall
151 + @ ; insert args into stack
155 + @ ; do the system call
161 + @ ; child sp is already in r1
162 + stmfd sp!, {r4, r7}
163 + @stmdb sp!, {r4, r7}
167 + ldr r7, =__NR_clone
172 + ldmfd sp!, {r4, r7}
173 + blt __unified_syscall @ (return code < 0): handle as an error
177 + tst ip, #CLONE_THREAD
180 + mov r0, #0xffff0fff
186 + ldr r7, =__NR_getpid
188 + str r0, [r1, #PID_OFFSET] @ ; not defined yet ??
189 + str r0, [r1, #TID_OFFSET] @ ; not defined yet ??
192 + @ ; pick the function arg and call address off the stack and execute
197 + @ ; and we're done, passing return value through r0
198 + b _exit @ branch to _exit (PIC safe)
205 movs r12, r0 @ check function pointer
208 1: b _exit @ branch to _exit (PIC safe)
211 diff -urN -x CVS dietlibc-0.31/arm/connect.S dietlibc/arm/connect.S
212 --- dietlibc-0.31/arm/connect.S 1970-01-01 01:00:00.000000000 +0100
213 +++ dietlibc/arm/connect.S 2008-09-05 17:13:29.000000000 +0200
217 +#include "syscalls.h"
219 +syscall(connect,connect)
222 diff -urN -x CVS dietlibc-0.31/arm/dyn_syscalls.S dietlibc/arm/dyn_syscalls.S
223 --- dietlibc-0.31/arm/dyn_syscalls.S 2005-10-08 23:22:09.000000000 +0200
224 +++ dietlibc/arm/dyn_syscalls.S 2008-07-07 14:31:53.000000000 +0200
226 /* ok now include all syscalls.s (*.S) and sysdep *.S */
231 #include "../syscalls.s/__getpagesize.S"
232 #include "../syscalls.s/__pread.S"
234 #include "../syscalls.s/sched_setparam.S"
235 #include "../syscalls.s/sched_setscheduler.S"
236 #include "../syscalls.s/sched_yield.S"
237 -#include "../syscalls.s/select.S"
238 #include "../syscalls.s/sendfile.S"
239 #include "../syscalls.s/sendfile64.S"
240 #include "../syscalls.s/setdomainname.S"
243 #include "__longjmp.S"
245 +#include "__guard.S"
246 diff -urN -x CVS dietlibc-0.31/arm/getpeername.S dietlibc/arm/getpeername.S
247 --- dietlibc-0.31/arm/getpeername.S 1970-01-01 01:00:00.000000000 +0100
248 +++ dietlibc/arm/getpeername.S 2008-09-05 17:13:29.000000000 +0200
252 +#include "syscalls.h"
254 +syscall(getpeername,getpeername)
257 diff -urN -x CVS dietlibc-0.31/arm/getsockname.S dietlibc/arm/getsockname.S
258 --- dietlibc-0.31/arm/getsockname.S 1970-01-01 01:00:00.000000000 +0100
259 +++ dietlibc/arm/getsockname.S 2008-09-05 17:13:29.000000000 +0200
263 +#include "syscalls.h"
265 +syscall(getsockname,getsockname)
268 diff -urN -x CVS dietlibc-0.31/arm/listen.S dietlibc/arm/listen.S
269 --- dietlibc-0.31/arm/listen.S 1970-01-01 01:00:00.000000000 +0100
270 +++ dietlibc/arm/listen.S 2008-09-05 17:13:29.000000000 +0200
274 +#include "syscalls.h"
276 +syscall(listen,listen)
279 diff -urN -x CVS dietlibc-0.31/arm/Makefile.add dietlibc/arm/Makefile.add
280 --- dietlibc-0.31/arm/Makefile.add 2002-05-09 03:05:10.000000000 +0200
281 +++ dietlibc/arm/Makefile.add 2008-09-05 17:13:29.000000000 +0200
284 -LIBOBJ+=$(OBJDIR)/md5asm.o
285 -CFLAGS+=-Os -fomit-frame-pointer -fstrict-aliasing -mhard-float
286 +LIBOBJ+=$(OBJDIR)/md5asm.o $(OBJDIR)/__aeabi_unwind_cpp.o
287 +CFLAGS+=-Os -fomit-frame-pointer -fstrict-aliasing
289 +CFLAGS+=-mabi=aapcs-linux -mfloat-abi=soft -mno-thumb-interwork
291 VPATH:=arm:syscalls.s:$(VPATH)
292 LIBGMON_OBJS+=$(OBJDIR)/mcount.o
293 diff -urN -x CVS dietlibc-0.31/arm/md5asm.S dietlibc/arm/md5asm.S
294 --- dietlibc-0.31/arm/md5asm.S 2002-03-08 11:56:15.000000000 +0100
295 +++ dietlibc/arm/md5asm.S 2008-09-05 17:13:29.000000000 +0200
308 @ void MD5Init (MD5_CTX* context);
310 diff -urN -x CVS dietlibc-0.31/arm/mmap.S dietlibc/arm/mmap.S
311 --- dietlibc-0.31/arm/mmap.S 2002-02-18 20:57:39.000000000 +0100
312 +++ dietlibc/arm/mmap.S 2008-12-02 22:50:42.000000000 +0100
316 #include "syscalls.h"
330 + mov r7, #__NR_mmap2
336 + mov pc, lr @ return
341 stmdb sp!, {r0, r1, r2, r3}
348 diff -urN -x CVS dietlibc-0.31/arm/recvfrom.S dietlibc/arm/recvfrom.S
349 --- dietlibc-0.31/arm/recvfrom.S 1970-01-01 01:00:00.000000000 +0100
350 +++ dietlibc/arm/recvfrom.S 2008-09-05 17:13:29.000000000 +0200
354 +#include "syscalls.h"
356 +syscall(recvfrom,recvfrom)
359 diff -urN -x CVS dietlibc-0.31/arm/recvmsg.S dietlibc/arm/recvmsg.S
360 --- dietlibc-0.31/arm/recvmsg.S 1970-01-01 01:00:00.000000000 +0100
361 +++ dietlibc/arm/recvmsg.S 2008-09-05 17:13:29.000000000 +0200
365 +#include "syscalls.h"
367 +syscall(recvmsg,recvmsg)
370 diff -urN -x CVS dietlibc-0.31/arm/recv.S dietlibc/arm/recv.S
371 --- dietlibc-0.31/arm/recv.S 1970-01-01 01:00:00.000000000 +0100
372 +++ dietlibc/arm/recv.S 2008-09-05 17:13:29.000000000 +0200
376 +#include "syscalls.h"
381 diff -urN -x CVS dietlibc-0.31/arm/sendmsg.S dietlibc/arm/sendmsg.S
382 --- dietlibc-0.31/arm/sendmsg.S 1970-01-01 01:00:00.000000000 +0100
383 +++ dietlibc/arm/sendmsg.S 2008-09-05 17:13:29.000000000 +0200
387 +#include "syscalls.h"
389 +syscall(sendmsg,sendmsg)
392 diff -urN -x CVS dietlibc-0.31/arm/send.S dietlibc/arm/send.S
393 --- dietlibc-0.31/arm/send.S 1970-01-01 01:00:00.000000000 +0100
394 +++ dietlibc/arm/send.S 2008-09-05 17:13:29.000000000 +0200
398 +#include "syscalls.h"
403 diff -urN -x CVS dietlibc-0.31/arm/sendto.S dietlibc/arm/sendto.S
404 --- dietlibc-0.31/arm/sendto.S 1970-01-01 01:00:00.000000000 +0100
405 +++ dietlibc/arm/sendto.S 2008-09-05 17:13:29.000000000 +0200
409 +#include "syscalls.h"
411 +syscall(sendto,sendto)
414 diff -urN -x CVS dietlibc-0.31/arm/setjmp.S dietlibc/arm/setjmp.S
415 --- dietlibc-0.31/arm/setjmp.S 2001-07-02 18:06:48.000000000 +0200
416 +++ dietlibc/arm/setjmp.S 2008-09-05 17:13:29.000000000 +0200
420 stmia r0, {r4-r11, sp, lr}
425 diff -urN -x CVS dietlibc-0.31/arm/setsockopt.S dietlibc/arm/setsockopt.S
426 --- dietlibc-0.31/arm/setsockopt.S 1970-01-01 01:00:00.000000000 +0100
427 +++ dietlibc/arm/setsockopt.S 2008-09-05 17:13:29.000000000 +0200
431 +#include "syscalls.h"
433 +syscall(setsockopt,setsockopt)
436 diff -urN -x CVS dietlibc-0.31/arm/shutdown.S dietlibc/arm/shutdown.S
437 --- dietlibc-0.31/arm/shutdown.S 1970-01-01 01:00:00.000000000 +0100
438 +++ dietlibc/arm/shutdown.S 2008-09-05 17:13:29.000000000 +0200
442 +#include "syscalls.h"
444 +syscall(shutdown,shutdown)
447 diff -urN -x CVS dietlibc-0.31/arm/socketpair.S dietlibc/arm/socketpair.S
448 --- dietlibc-0.31/arm/socketpair.S 1970-01-01 01:00:00.000000000 +0100
449 +++ dietlibc/arm/socketpair.S 2008-09-05 17:13:29.000000000 +0200
453 +#include "syscalls.h"
455 +syscall(socketpair,socketpair)
458 diff -urN -x CVS dietlibc-0.31/arm/socket.S dietlibc/arm/socket.S
459 --- dietlibc-0.31/arm/socket.S 1970-01-01 01:00:00.000000000 +0100
460 +++ dietlibc/arm/socket.S 2008-09-05 17:13:29.000000000 +0200
464 +#include "syscalls.h"
466 +syscall(socket,socket)
469 diff -urN -x CVS dietlibc-0.31/arm/start.S dietlibc/arm/start.S
470 --- dietlibc-0.31/arm/start.S 2006-04-04 07:35:14.000000000 +0200
471 +++ dietlibc/arm/start.S 2008-09-05 17:13:29.000000000 +0200
473 #include "syscalls.h"
492 + mov fp, #0 @ clear the frame pointer
493 + ldr a1, [sp], #4 @ argc
496 + add a3, a2, a1, lsl #2 @ &argv[argc]
497 + add a3, a3, #4 @ envp
498 + str a3, [ip, #0] @ environ = envp
502 +@ The exit status from main() is already in r0.
503 +@ We need to branch to 'exit' in case we have linked with 'atexit'.
511 + swi 0 @ never returns.
528 diff -urN -x CVS dietlibc-0.31/arm/syscalls.h dietlibc/arm/syscalls.h
529 --- dietlibc-0.31/arm/syscalls.h 2007-08-24 23:19:33.000000000 +0200
530 +++ dietlibc/arm/syscalls.h 2008-09-30 23:02:35.000000000 +0200
532 -#define __NR_SYSCALL_BASE 0x900000
533 +#ifndef _ARM_SYSCALL_H
534 +#define _ARM_SYSCALL_H 1
536 +#define __NR_OABI_SYSCALL_BASE 0x900000
538 +#if defined(__thumb__) || defined(__ARM_EABI__)
539 +#define __NR_SYSCALL_BASE 0
541 +#define __NR_SYSCALL_BASE __NR_OABI_SYSCALL_BASE
545 +#define __NR_restart_syscall (__NR_SYSCALL_BASE+ 0)
546 #define __NR_exit (__NR_SYSCALL_BASE+ 1)
547 #define __NR_fork (__NR_SYSCALL_BASE+ 2)
548 #define __NR_read (__NR_SYSCALL_BASE+ 3)
549 @@ -126,10 +137,10 @@
550 #define __NR_adjtimex (__NR_SYSCALL_BASE+124)
551 #define __NR_mprotect (__NR_SYSCALL_BASE+125)
552 #define __NR_sigprocmask (__NR_SYSCALL_BASE+126)
553 -#define __NR_create_module (__NR_SYSCALL_BASE+127)
554 + /* 127 was sys_create_module */
555 #define __NR_init_module (__NR_SYSCALL_BASE+128)
556 #define __NR_delete_module (__NR_SYSCALL_BASE+129)
557 -#define __NR_get_kernel_syms (__NR_SYSCALL_BASE+130)
558 + /* 130 was sys_get_kernel_syms */
559 #define __NR_quotactl (__NR_SYSCALL_BASE+131)
560 #define __NR_getpgid (__NR_SYSCALL_BASE+132)
561 #define __NR_fchdir (__NR_SYSCALL_BASE+133)
563 #define __NR_setresuid (__NR_SYSCALL_BASE+164)
564 #define __NR_getresuid (__NR_SYSCALL_BASE+165)
565 /* 166 was sys_vm86 */
566 -#define __NR_query_module (__NR_SYSCALL_BASE+167)
567 + /* 167 was sys_query_module */
568 #define __NR_poll (__NR_SYSCALL_BASE+168)
569 #define __NR_nfsservctl (__NR_SYSCALL_BASE+169)
570 #define __NR_setresgid (__NR_SYSCALL_BASE+170)
572 #define __NR_rt_sigtimedwait (__NR_SYSCALL_BASE+177)
573 #define __NR_rt_sigqueueinfo (__NR_SYSCALL_BASE+178)
574 #define __NR_rt_sigsuspend (__NR_SYSCALL_BASE+179)
575 -#define __NR_pread (__NR_SYSCALL_BASE+180)
576 -#define __NR_pwrite (__NR_SYSCALL_BASE+181)
577 +#define __NR_pread64 (__NR_SYSCALL_BASE+180)
578 +#define __NR_pwrite64 (__NR_SYSCALL_BASE+181)
579 #define __NR_chown (__NR_SYSCALL_BASE+182)
580 #define __NR_getcwd (__NR_SYSCALL_BASE+183)
581 #define __NR_capget (__NR_SYSCALL_BASE+184)
583 #define __NR_fstatfs64 (__NR_SYSCALL_BASE+267)
584 #define __NR_tgkill (__NR_SYSCALL_BASE+268)
585 #define __NR_utimes (__NR_SYSCALL_BASE+269)
586 -#define __NR_fadvise64 (__NR_SYSCALL_BASE+270)
587 +#define __NR_arm_fadvise64_64 (__NR_SYSCALL_BASE+270)
588 #define __NR_pciconfig_iobase (__NR_SYSCALL_BASE+271)
589 #define __NR_pciconfig_read (__NR_SYSCALL_BASE+272)
590 #define __NR_pciconfig_write (__NR_SYSCALL_BASE+273)
591 @@ -280,10 +291,38 @@
592 #define __NR_mq_notify (__NR_SYSCALL_BASE+278)
593 #define __NR_mq_getsetattr (__NR_SYSCALL_BASE+279)
594 #define __NR_waitid (__NR_SYSCALL_BASE+280)
596 +#define __NR_socket (__NR_SYSCALL_BASE+281)
597 +#define __NR_bind (__NR_SYSCALL_BASE+282)
598 +#define __NR_connect (__NR_SYSCALL_BASE+283)
599 +#define __NR_listen (__NR_SYSCALL_BASE+284)
600 +#define __NR_accept (__NR_SYSCALL_BASE+285)
601 +#define __NR_getsockname (__NR_SYSCALL_BASE+286)
602 +#define __NR_getpeername (__NR_SYSCALL_BASE+287)
603 +#define __NR_socketpair (__NR_SYSCALL_BASE+288)
604 +#define __NR_send (__NR_SYSCALL_BASE+289)
605 +#define __NR_sendto (__NR_SYSCALL_BASE+290)
606 +#define __NR_recv (__NR_SYSCALL_BASE+291)
607 +#define __NR_recvfrom (__NR_SYSCALL_BASE+292)
608 +#define __NR_shutdown (__NR_SYSCALL_BASE+293)
609 +#define __NR_setsockopt (__NR_SYSCALL_BASE+294)
610 +#define __NR_getsockopt (__NR_SYSCALL_BASE+295)
611 +#define __NR_sendmsg (__NR_SYSCALL_BASE+296)
612 +#define __NR_recvmsg (__NR_SYSCALL_BASE+297)
613 +#define __NR_semop (__NR_SYSCALL_BASE+298)
614 +#define __NR_semget (__NR_SYSCALL_BASE+299)
615 +#define __NR_semctl (__NR_SYSCALL_BASE+300)
616 +#define __NR_msgsnd (__NR_SYSCALL_BASE+301)
617 +#define __NR_msgrcv (__NR_SYSCALL_BASE+302)
618 +#define __NR_msgget (__NR_SYSCALL_BASE+303)
619 +#define __NR_msgctl (__NR_SYSCALL_BASE+304)
620 +#define __NR_shmat (__NR_SYSCALL_BASE+305)
621 +#define __NR_shmdt (__NR_SYSCALL_BASE+306)
622 +#define __NR_shmget (__NR_SYSCALL_BASE+307)
623 +#define __NR_shmctl (__NR_SYSCALL_BASE+308)
624 #define __NR_add_key (__NR_SYSCALL_BASE+309)
625 #define __NR_request_key (__NR_SYSCALL_BASE+310)
626 #define __NR_keyctl (__NR_SYSCALL_BASE+311)
627 +#define __NR_semtimedop (__NR_SYSCALL_BASE+312)
628 #define __NR_vserver (__NR_SYSCALL_BASE+313)
629 #define __NR_ioprio_set (__NR_SYSCALL_BASE+314)
630 #define __NR_ioprio_get (__NR_SYSCALL_BASE+315)
632 #define __NR_mbind (__NR_SYSCALL_BASE+319)
633 #define __NR_get_mempolicy (__NR_SYSCALL_BASE+320)
634 #define __NR_set_mempolicy (__NR_SYSCALL_BASE+321)
635 +#define __NR_openat (__NR_SYSCALL_BASE+322)
636 +#define __NR_mkdirat (__NR_SYSCALL_BASE+323)
637 +#define __NR_mknodat (__NR_SYSCALL_BASE+324)
638 +#define __NR_fchownat (__NR_SYSCALL_BASE+325)
639 +#define __NR_futimesat (__NR_SYSCALL_BASE+326)
640 +#define __NR_fstatat64 (__NR_SYSCALL_BASE+327)
641 +#define __NR_unlinkat (__NR_SYSCALL_BASE+328)
642 +#define __NR_renameat (__NR_SYSCALL_BASE+329)
643 +#define __NR_linkat (__NR_SYSCALL_BASE+330)
644 +#define __NR_symlinkat (__NR_SYSCALL_BASE+331)
645 +#define __NR_readlinkat (__NR_SYSCALL_BASE+332)
646 +#define __NR_fchmodat (__NR_SYSCALL_BASE+333)
647 +#define __NR_faccessat (__NR_SYSCALL_BASE+334)
648 + /* 335 for pselect6 */
649 + /* 336 for ppoll */
650 +#define __NR_unshare (__NR_SYSCALL_BASE+337)
651 +#define __NR_set_robust_list (__NR_SYSCALL_BASE+338)
652 +#define __NR_get_robust_list (__NR_SYSCALL_BASE+339)
653 +#define __NR_splice (__NR_SYSCALL_BASE+340)
654 +#define __NR_arm_sync_file_range (__NR_SYSCALL_BASE+341)
655 +#define __NR_tee (__NR_SYSCALL_BASE+342)
656 +#define __NR_vmsplice (__NR_SYSCALL_BASE+343)
657 +#define __NR_move_pages (__NR_SYSCALL_BASE+344)
658 +#define __NR_getcpu (__NR_SYSCALL_BASE+345)
659 + /* 346 for epoll_pwait */
660 +#define __NR_kexec_load (__NR_SYSCALL_BASE+347)
661 +#define __NR_utimensat (__NR_SYSCALL_BASE+348)
662 +#define __NR_signalfd (__NR_SYSCALL_BASE+349)
663 +#define __NR_timerfd (__NR_SYSCALL_BASE+350)
664 +#define __NR_eventfd (__NR_SYSCALL_BASE+351)
665 +#define __NR_fallocate (__NR_SYSCALL_BASE+352)
666 +#define __NR_timerfd_settime (__NR_SYSCALL_BASE+353)
667 +#define __NR_timerfd_gettime (__NR_SYSCALL_BASE+354)
670 * The following SWIs are ARM private.
672 #define __ARM_NR_usr32 (__ARM_NR_BASE+4)
673 #define __ARM_NR_set_tls (__ARM_NR_BASE+5)
676 + * The following syscalls are obsolete and no longer available for EABI.
678 +#if defined(__ARM_EABI__) && !defined(__KERNEL__)
684 +#undef __NR_getrlimit
688 +#undef __NR_socketcall
694 /* ok the next few values are for the optimization of the unified syscalls
696 * If the syscall has #arguments
698 #define __ARGS_mq_getsetattr 0
699 #define __ARGS_waitid 0
701 +#define __ARGS_socket 0
702 +#define __ARGS_bind 0
703 +#define __ARGS_connect 0
704 +#define __ARGS_listen 0
705 +#define __ARGS_accept 0
706 +#define __ARGS_getsockname 0
707 +#define __ARGS_getpeername 0
708 +#define __ARGS_socketpair 0
709 +#define __ARGS_send 0
710 +#define __ARGS_sendto 0
711 +#define __ARGS_recv 0
712 +#define __ARGS_recvfrom 0
713 +#define __ARGS_shutdown 0
714 +#define __ARGS_setsockopt 0
715 +#define __ARGS_getsockopt 0
716 +#define __ARGS_sendmsg 0
717 +#define __ARGS_recvmsg 0
718 +#define __ARGS_semop 0
719 +#define __ARGS_semget 0
720 +#define __ARGS_semctl 0
721 +#define __ARGS_msgsnd 0
722 +#define __ARGS_msgrcv 0
723 +#define __ARGS_msgget 0
724 +#define __ARGS_msgctl 0
725 +#define __ARGS_shmat 0
726 +#define __ARGS_shmdt 0
727 +#define __ARGS_shmget 0
728 +#define __ARGS_shmctl 0
730 #define __ARGS_add_key 1
731 #define __ARGS_request_key 1
732 #define __ARGS_keyctl 0
734 #define __ARGS_get_mempolicy 1
735 #define __ARGS_set_mempolicy 1
737 +#define __ARGS_openat 0
738 +#define __ARGS_mkdirat 0
739 +#define __ARGS_mknodat 0
740 +#define __ARGS_fchownat 1
741 +#define __ARGS_futimesat 0
742 +#define __ARGS_fstatat64 0
743 +#define __ARGS_unlinkat 0
744 +#define __ARGS_renameat 0
745 +#define __ARGS_linkat 1
746 +#define __ARGS_symlinkat 0
747 +#define __ARGS_readlinkat 0
748 +#define __ARGS_fchmodat 0
749 +#define __ARGS_faccessat 0
750 + /* 335 for pselect6 */
751 + /* 336 for ppoll */
752 +#define __ARGS_unshare 0
753 +#define __ARGS_set_robust_list 0
754 +#define __ARGS_get_robust_list 0
755 +#define __ARGS_splice 1
756 +#define __ARGS_arm_sync_file_range 0
757 +#define __ARGS_sync_file_range2 0
758 +#define __ARGS_tee 0
759 +#define __ARGS_vmsplice 0
760 +#define __ARGS_move_pages 1
761 +#define __ARGS_getcpu 0
762 + /* 346 for epoll_pwait */
763 +#define __ARGS_kexec_load 0
764 +#define __ARGS_utimensat 0
765 +#define __ARGS_signalfd 0
766 +#define __ARGS_timerfd 0
767 +#define __ARGS_eventfd 0
768 +#define __ARGS_fallocate 0
769 +#define __ARGS_timerfd_settime 0
770 +#define __ARGS_timerfd_gettime 0
777 +#define syscall_weak(name,wsym,sym) __syscall_weak __NR_##name, wsym, sym, __ARGS_##name
778 +.macro __syscall_weak name wsym sym typ
780 +.type \wsym,function
786 + stmfd sp!,{r4,r5,r7,lr}
791 + b __unified_syscall
795 +#define syscall(name,sym) __syscall __NR_##name, sym, __ARGS_##name
796 +.macro __syscall name sym typ
801 + stmfd sp!,{r4,r5,r7,lr}
806 + b __unified_syscall
811 #define syscall_weak(name,wsym,sym) __syscall_weak $__NR_##name, wsym, sym, __ARGS_##name
812 .macro __syscall_weak name wsym sym typ
821 diff -urN -x CVS dietlibc-0.31/arm/unified.S dietlibc/arm/unified.S
822 --- dietlibc-0.31/arm/unified.S 2002-02-28 17:13:20.000000000 +0100
823 +++ dietlibc/arm/unified.S 2008-09-05 17:13:29.000000000 +0200
825 #include <dietfeatures.h>
834 .global __unified_syscall
835 .global __unified_syscall4
848 + ldmfd sp!,{r4,r5,r7,pc}
853 +/* here we go and "reuse" the return for weak-void functions */
854 +#include "dietuglyweaks.h"
859 ldmia sp!, {r4, r5, r6}
862 #ifndef WANT_THREAD_SAFE
867 diff -urN -x CVS dietlibc-0.31/arm/waitpid.S dietlibc/arm/waitpid.S
868 --- dietlibc-0.31/arm/waitpid.S 2004-11-30 17:26:20.000000000 +0100
869 +++ dietlibc/arm/waitpid.S 2008-09-05 17:13:29.000000000 +0200
878 .type waitpid, %function
880 diff -urN -x CVS dietlibc-0.31/CHANGES dietlibc/CHANGES
881 --- dietlibc-0.31/CHANGES 2007-08-03 22:58:33.000000000 +0200
882 +++ dietlibc/CHANGES 2009-03-17 00:17:58.000000000 +0100
885 + add mbsinit, mbrlen, mbtowc, wctomb, mbrtowc, wcrtomb, wcwidth
886 + add btowc, wctype, iswctype
887 + add some wide char routines
888 + add statvfs, fstatvfs
889 + add some amd64 asm string routines
890 + add some constants for inotify
891 + several fixes from Enrico Scholz (printf, string routines on big endian)
892 + add some more syscalls
893 + some minor cleanups
894 + shrink some string functions (Kris Katterjohn)
895 + prepare x86_64 for syscall numbers > 255
896 + fix unaligned memcpy if WANT_SMALL_STRING_ROUTINES is not defined
898 + fix utmp, add utmpx support (R.L. Horn)
899 + fix the dynamic library for the ARM architecture (Gernot Tenchio)
900 + get ARM port to work with EABI (Tristan Newby)
901 + fix of scanf with negative floats (Andre Oliveira)
902 + use vsyscall to do time(2) on x86-64
903 + implement back references in basic regexes
904 + make regex faster (coalesce n CHAR matches to one STRING match)
906 + use randomness passed in ELF auxvec instead of /dev/urandom in startup
907 + (strace looks cleaner now)
908 + use ELF auxvec to implement getpagesize
909 + support thread local storage (w00t!!!!)
910 + don't crash in getaddrinfo if hints is NULL (Gernot Tenchio)
911 + add -D_REENTRANT for -pthread in diet
914 getopt_long and getopt_long_only now refuse ambiguous abbreviations
915 fix printf %u/%x on 64-bit platforms
916 diff -urN -x CVS dietlibc-0.31/contrib/debug-realloc.c dietlibc/contrib/debug-realloc.c
917 --- dietlibc-0.31/contrib/debug-realloc.c 2002-04-24 00:04:58.000000000 +0200
918 +++ dietlibc/contrib/debug-realloc.c 2007-11-18 01:59:08.000000000 +0100
921 #include <sys/mman.h>
927 static struct malloced {
928 unsigned long len,maplen;
929 struct malloced* next;
930 + unsigned long magic;
933 -void* malloc(size_t size) {
934 +static const unsigned long MAGIC=(unsigned long)0xfefec0dedeadbeefull;
936 +static void checkmagic() {
937 + struct malloced* x=root;
939 + if (x->magic != MAGIC)
945 +static void* domalloc(size_t size) {
947 unsigned long s=size+sizeof(struct malloced);
948 - s=(s+4096+4095)&~4095;
950 + s=(s+4096+4095)&~4095; // add one page, and round up to fill one page
951 n=mmap(0,s,PROT_NONE,MAP_PRIVATE|MAP_ANONYMOUS,-1,0);
952 if (n==MAP_FAILED) return 0;
953 m=n-size; while (m<n) m+=4096;
955 ((struct malloced*)n)->len=size;
956 ((struct malloced*)n)->maplen=s;
957 ((struct malloced*)n)->next=root;
958 + ((struct malloced*)n)->magic=MAGIC;
959 root=(struct malloced*)n;
963 -void free(void* ptr) {
964 +void* malloc(size_t size) {
965 + void* m=domalloc(size);;
967 + printf("malloc(%zu) -> %p\n",size,m);
972 +static void dofree(void* ptr) {
973 struct malloced** x=&root;
976 if (((char*)(*x))+sizeof(struct malloced)<(char*)ptr &&
977 ((char*)(*x))+4096>(char*)ptr) {
982 +void free(void* ptr) {
984 + printf("free(%p)\n",ptr);
989 void *realloc(void *ptr, size_t size) {
990 unsigned long oldsize=0;
991 - struct malloced** x=&root;
992 + struct malloced* x=root;
996 - if (((char*)(*x))+sizeof(struct malloced)<(char*)ptr &&
997 - ((char*)(*x))+4096>(char*)ptr) {
1001 + if (((char*)x)+sizeof(struct malloced)<(char*)ptr &&
1002 + ((char*)x)+4096>(char*)ptr) {
1009 + if (oldsize==(unsigned long)-1)
1012 - fnord=malloc(size);
1013 + fnord=domalloc(size);
1014 memcpy(fnord,ptr,size>oldsize?oldsize:size);
1015 - if (oldsize) free(ptr);
1016 + if (oldsize) dofree(ptr);
1018 + printf("realloc(%p,%zu) -> %p\n",ptr,size,fnord);
1022 diff -urN -x CVS dietlibc-0.31/contrib/dnsd.c dietlibc/contrib/dnsd.c
1023 --- dietlibc-0.31/contrib/dnsd.c 2007-01-31 22:09:18.000000000 +0100
1024 +++ dietlibc/contrib/dnsd.c 2008-09-30 23:02:35.000000000 +0200
1029 -#include <sys/poll.h>
1032 #include <strings.h>
1036 struct sockaddr_in mysa4;
1037 struct sockaddr_in6 mysa6;
1040 +static int scan_fromhex(unsigned char c) {
1042 + if (c<=9) return c;
1045 + if (c<6) return c+10;
1047 +/* more readable but creates worse code:
1048 + if (c>='0' && c<='9')
1050 + else if (c>='A' && c<='F')
1052 + else if (c>='a' && c<='f')
1058 +static void getip(int interface) {
1060 + struct cmsghdr* x;
1061 + memset(&mysa4,0,sizeof(mysa4));
1062 + memset(&mysa6,0,sizeof(mysa6));
1063 + for (x=CMSG_FIRSTHDR(&mh); x; x=CMSG_NXTHDR(&mh,x))
1064 + if (x->cmsg_level==SOL_IP && x->cmsg_type==IP_PKTINFO)
1065 + mysa4.sin_addr=((struct in_pktinfo*)(CMSG_DATA(x)))->ipi_spec_dst;
1067 + fd=open("/proc/net/if_inet6",O_RDONLY);
1069 + char buf[1024]; /* increase as necessary */
1071 + len=read(fd,buf,sizeof buf);
1075 + char* max=buf+len;
1077 + /* "fec000000000000102c09ffffe53fc52 01 40 40 00 eth0" */
1080 + for (i=0; i<16; ++i) {
1081 + a=scan_fromhex(c[i*2]);
1082 + b=scan_fromhex(c[i*2+1]);
1083 + if (a<0 || b<0) goto kaputt;
1084 + mysa6.sin6_addr.s6_addr[i]=(a<<4)+b;
1087 + a=scan_fromhex(c[33]);
1088 + b=scan_fromhex(c[34]);
1090 + if (a<0 || b<0) goto kaputt;
1091 + if ((a<<4)+b == interface) {
1095 + while (c<max && *c!='\n') ++c;
1099 + if (!ok) memset(&mysa6,0,sizeof(mysa6));
1105 static void handle(int s,char* buf,int len,int interface,int llmnr) {
1112 + printf("called with interface==0!\n");
1114 if (len<8*2) return; /* too short */
1116 if ((buf[2]&(llmnr?0xfd:0xf8)) != 0) return; /* not query */
1118 if (buf[8] || buf[9]) return; /* name server count must be 0 */
1119 if (buf[10] || buf[11]) return; /* additional record count must be 0 */
1122 + printf("got %s request for \"%.*s\"",llmnr?"LLMNR":"zeroconf mDNS",(int)(unsigned char)buf[0],buf+1);
1124 if (buf[0]==namelen && !strncasecmp(buf+1,myhostname,namelen)) {
1128 if (type==1 || type==255) { /* A or ANY, we can do that */
1130 static int v4sock=-1;
1132 ++obuf[7]; /* one answer */
1133 memcpy(obuf+slen,"\xc0\x0c" /* goofy compression */
1135 @@ -106,69 +180,11 @@
1136 struct sockaddr_in6 sa6;
1137 struct pollfd pfd[4];
1142 #define PKGSIZE 1500
1143 char buf[PKGSIZE+1];
1145 -static int scan_fromhex(unsigned char c) {
1146 - if (c>='0' && c<='9')
1148 - else if (c>='A' && c<='F')
1150 - else if (c>='a' && c<='f')
1155 -static void getip(int interface) {
1157 - struct cmsghdr* x;
1158 - memset(&mysa4,0,sizeof(mysa4));
1159 - memset(&mysa6,0,sizeof(mysa6));
1160 - for (x=CMSG_FIRSTHDR(&mh); x; x=CMSG_NXTHDR(&mh,x))
1161 - if (x->cmsg_level==SOL_IP && x->cmsg_type==IP_PKTINFO)
1162 - mysa4.sin_addr=((struct in_pktinfo*)(CMSG_DATA(x)))->ipi_spec_dst;
1164 - fd=open("/proc/net/if_inet6",O_RDONLY);
1166 - char buf[1024]; /* increase as necessary */
1168 - len=read(fd,buf,sizeof buf);
1172 - char* max=buf+len;
1174 - /* "fec000000000000102c09ffffe53fc52 01 40 40 00 eth0" */
1177 - for (i=0; i<16; ++i) {
1178 - a=scan_fromhex(c[i*2]);
1179 - b=scan_fromhex(c[i*2+1]);
1180 - if (a<0 || b<0) goto kaputt;
1181 - mysa6.sin6_addr.s6_addr[i]=(a<<4)+b;
1184 - a=scan_fromhex(c[33]);
1185 - b=scan_fromhex(c[34]);
1187 - if (a<0 || b<0) goto kaputt;
1188 - if ((a<<4)+b == interface) {
1192 - while (c<max && *c!='\n') ++c;
1196 - if (!ok) memset(&mysa6,0,sizeof(mysa6));
1204 for (x=CMSG_FIRSTHDR(&mh); x; x=CMSG_NXTHDR(&mh,x))
1207 static void recv4(int s) {
1212 mh.msg_namelen=sizeof(sa4);
1213 @@ -190,17 +205,26 @@
1214 peer=(struct sockaddr*)&sa4;
1223 - handle(s,buf,len,interface,s==ls4);
1224 + handle(s,buf,len,v4if(),s==ls4);
1227 static void recv6(int s) {
1230 + char addrbuf[INET6_ADDRSTRLEN];
1231 + char ifbuf[IFNAMSIZ];
1235 mh.msg_namelen=sizeof(sa6);
1237 + mh.msg_control=abuf;
1238 + mh.msg_controllen=sizeof(abuf);
1240 if ((len=recvmsg(s,&mh,0))==-1) {
1243 @@ -208,18 +232,31 @@
1244 peer=(struct sockaddr*)&sa6;
1247 - if (IN6_IS_ADDR_V4MAPPED(sa6.sin6_addr.s6_addr))
1248 + if (IN6_IS_ADDR_V4MAPPED(sa6.sin6_addr.s6_addr)) {
1252 + inet_ntop(AF_INET,(char*)(sa6.sin6_addr.s6_addr)+12,addrbuf,sizeof addrbuf);
1253 + if_indextoname(interface,ifbuf);
1254 + printf("v4: %s: ",ifbuf);
1257 interface=sa6.sin6_scope_id;
1261 + inet_ntop(AF_INET6,sa6.sin6_addr.s6_addr,addrbuf,sizeof addrbuf);
1262 + if_indextoname(interface,ifbuf);
1263 + printf("v6: %s: ",ifbuf);
1267 handle(s,buf,len,interface,s==ls6);
1269 + printf(" from %s\n",addrbuf);
1273 static void init_sockets(int* sock6,int* sock4,int port,char* v6ip,char* v4ip) {
1276 *sock6=-1; *sock4=-1;
1277 s6=socket(PF_INET6,SOCK_DGRAM,IPPROTO_UDP);
1278 s4=socket(PF_INET,SOCK_DGRAM,IPPROTO_UDP);
1283 + setsockopt(s6,SOL_SOCKET,SO_REUSEADDR,&one,sizeof(one));
1284 memset(&sa6,0,sizeof(sa6));
1285 sa6.sin6_family=PF_INET6;
1286 sa6.sin6_port=htons(port);
1291 + setsockopt(s4,SOL_SOCKET,SO_REUSEADDR,&one,sizeof(one));
1292 memset(&sa4,0,sizeof(sa4));
1293 sa4.sin_family=PF_INET;
1294 sa4.sin_port=htons(port);
1295 diff -urN -x CVS dietlibc-0.31/diet.c dietlibc/diet.c
1296 --- dietlibc-0.31/diet.c 2006-08-27 15:49:00.000000000 +0200
1297 +++ dietlibc/diet.c 2009-03-17 00:17:58.000000000 +0100
1299 "sparc","-Os","-mcpu=supersparc",0,
1300 "sparc64","-Os","-m64","-mhard-quad-float",0,
1301 "alpha","-Os","-fomit-frame-pointer",0,
1302 +#ifdef __ARM_EABI__
1303 + "arm","-Os","-fomit-frame-pointer","-mfloat-abi=soft","-meabi=4",0,
1305 "arm","-Os","-fomit-frame-pointer",0,
1307 "mips","-Os","-fomit-frame-pointer","-mno-abicalls","-fno-pic","-G","0",0,
1308 "mipsel","-Os","-fomit-frame-pointer","-mno-abicalls","-fno-pic","-G","0",0,
1309 "ppc","-Os","-fomit-frame-pointer","-mpowerpc-gpopt","-mpowerpc-gfxopt",0,
1312 const char *nostdlib="-nostdlib";
1313 const char *libgcc="-lgcc";
1314 + char *libpthread="-lpthread";
1316 char dashstatic[]="-static";
1320 preprocess=compile=1;
1322 -/* we need to add -nostdlib if we are not compiling*/
1323 +/* we need to add -nostdlib if we are not compiling */
1328 if (!strcmp(argv[i],"-o"))
1329 if (!compile) _link=1;
1332 newargv=alloca(sizeof(char*)*(argc+100));
1333 a=alloca(strlen(diethome)+20);
1334 b=alloca(strlen(platform)+20);
1335 @@ -315,6 +321,11 @@
1336 if (_link) { *dest++=d; }
1338 for (i=2; i<argc; ++i) {
1339 + if (!strcmp(argv[i],"-pthread")) {
1340 + *dest++="-D_REENTRANT";
1341 + if (_link) *dest++="-lpthread";
1345 if (argv[i][0]=='-' && (argv[i][1]=='O' || argv[i][1]=='f' ||
1346 (argv[i][1]=='m' && argv[i][2]!='3' && argv[i][2]!='6'))) {
1347 diff -urN -x CVS dietlibc-0.31/dietfeatures.h dietlibc/dietfeatures.h
1348 --- dietlibc-0.31/dietfeatures.h 2007-08-03 22:58:33.000000000 +0200
1349 +++ dietlibc/dietfeatures.h 2009-02-26 21:51:54.000000000 +0100
1351 /* use errno_location instead of errno */
1352 #define WANT_THREAD_SAFE
1354 +/* support __thread */
1357 /* make the startcode, etc. dynamic aware ({con,de}structors) */
1358 /* #define WANT_DYNAMIC */
1361 #define WANT_LD_SO_GDB_SUPPORT
1363 /* do you want smaller or faster string routines? */
1364 -/* #define WANT_FASTER_STRING_ROUTINES */
1365 +#define WANT_FASTER_STRING_ROUTINES
1367 /* define this to have strncpy zero-fill and not just zero-terminate the
1369 @@ -111,20 +114,10 @@
1370 /* Include support for ProPolice/SSP, calls guard_setup */
1371 /* ProPolice is part of gcc 4.1 and up, there were patches for earlier
1372 * versions. To make use of this, compile your application with
1373 - * -fstack-protector. On i386, enabling this option with
1374 - * WANT_SSP_URANDOM and then not using -fstack-protector enlarges a
1375 - * binary by 152 bytes. */
1376 + * -fstack-protector. */
1377 #if (__GNUC__>4) || ((__GNUC__==4) && (__GNUC_MINOR__>=1))
1380 -/* Choose which canary seeder you want you can choose
1381 - * both but it will check urandom first and use xor as
1382 - * a fallback. xor is lighter but weaker */
1383 -#define WANT_SSP_URANDOM
1384 -/* The XOR seeder is completely predictable and should not be used
1385 - * unless you don't have a /dev/urandom, and even then it's a bad idea. */
1386 -/* #define WANT_SSP_XOR */
1391 diff -urN -x CVS dietlibc-0.31/dietstring.h dietlibc/dietstring.h
1392 --- dietlibc-0.31/dietstring.h 2003-12-21 13:06:36.000000000 +0100
1393 +++ dietlibc/dietstring.h 2008-02-19 01:28:13.000000000 +0100
1395 # define STRALIGN(x) (((unsigned long)x&3)?4-((unsigned long)x&3):0)
1398 +/* GFC(x) - returns first character */
1399 +/* INCSTR(x) - moves to next character */
1400 +#if __BYTE_ORDER == __LITTLE_ENDIAN
1401 +# define GFC(x) ((x)&0xff)
1402 +# define INCSTR(x) do { x >>= 8; } while (0)
1404 +# define GFC(x) (((x)>>(sizeof(x)*8-8))&0xff)
1405 +# define INCSTR(x) do { x <<= 8; } while (0)
1408 #define UNALIGNED(x,y) (((unsigned long)x & (sizeof (unsigned long)-1)) ^ ((unsigned long)y & (sizeof (unsigned long)-1)))
1410 #endif /* _DIET_STRING_H_ */
1411 diff -urN -x CVS dietlibc-0.31/dyn_start.c dietlibc/dyn_start.c
1412 --- dietlibc-0.31/dyn_start.c 2005-09-21 09:33:08.000000000 +0200
1413 +++ dietlibc/dyn_start.c 2008-04-12 00:51:11.000000000 +0200
1416 int main(int argc, char **argv, char **envp);
1419 + /* GT: segfaults on arm, don't know why (for now) */
1420 void _dl_aux_init_from_envp(char **envp);
1421 _dl_aux_init_from_envp(envp);
1424 if (dl_init) atexit(dl_init);
1426 diff -urN -x CVS dietlibc-0.31/FAQ dietlibc/FAQ
1427 --- dietlibc-0.31/FAQ 2007-04-02 07:31:53.000000000 +0200
1428 +++ dietlibc/FAQ 2008-08-30 15:59:17.000000000 +0200
1429 @@ -331,3 +331,14 @@
1430 diet-dyn gcc -Wl,--hash-style=sysv -shared -o libx.so x.c
1431 ^^^^^^^^^^^^^^^^^^^^^
1434 +Q: How do I compile OpenSSL with dietlibc?
1435 +A: Here's how I do it:
1437 + ./config --prefix=/opt/diet no-dso
1438 + make libssl.pc openssl.pc
1439 + for i in libssl.pc openssl.pc Makefile; do (echo ",s/ *-ldl//g"; echo w) | ed $i; done
1440 + make CC="diet -Os gcc -pipe -nostdinc"
1442 +Then the libraries go to /opt/diet/lib, so you still need a symlink to
1443 +lib-i386 or whatever your architecture is.
1444 diff -urN -x CVS dietlibc-0.31/i386/dyn_syscalls.S dietlibc/i386/dyn_syscalls.S
1445 --- dietlibc-0.31/i386/dyn_syscalls.S 2006-10-13 22:11:13.000000000 +0200
1446 +++ dietlibc/i386/dyn_syscalls.S 2008-12-27 20:53:16.000000000 +0100
1448 #include "../syscalls.s/lgetxattr.S"
1449 #include "../syscalls.s/fgetxattr.S"
1451 +#include "../syscalls.s/timerfd.S"
1452 +#include "../syscalls.s/__signalfd.S"
1456 /* oh what a kludge! */
1457 diff -urN -x CVS dietlibc-0.31/i386/syscalls.h dietlibc/i386/syscalls.h
1458 --- dietlibc-0.31/i386/syscalls.h 2007-01-10 23:51:09.000000000 +0100
1459 +++ dietlibc/i386/syscalls.h 2008-09-30 23:02:35.000000000 +0200
1460 @@ -318,6 +318,13 @@
1461 #define __NR_move_pages 317
1462 #define __NR_getcpu 318
1463 #define __NR_epoll_pwait 319
1464 +#define __NR_utimensat 320
1465 +#define __NR_signalfd 321
1466 +#define __NR_timerfd 322
1467 +#define __NR_eventfd 323
1468 +#define __NR_fallocate 324
1469 +#define __NR_timerfd_settime 325
1470 +#define __NR_timerfd_gettime 326
1473 #define syscall_weak(name,wsym,sym) \
1474 diff -urN -x CVS dietlibc-0.31/ia64/syscalls.h dietlibc/ia64/syscalls.h
1475 --- dietlibc-0.31/ia64/syscalls.h 2006-09-19 00:08:39.000000000 +0200
1476 +++ dietlibc/ia64/syscalls.h 2008-09-30 23:02:35.000000000 +0200
1477 @@ -279,7 +279,16 @@
1478 #define __NR_sync_file_range 1300
1479 #define __NR_tee 1301
1480 #define __NR_vmsplice 1302
1482 +#define __NR_fallocate 1303
1483 +#define __NR_getcpu 1304
1484 +#define __NR_epoll_pwait 1305
1485 +#define __NR_utimensat 1306
1486 +#define __NR_signalfd 1307
1487 +#define __NR_timerfd 1308
1488 +#define __NR_eventfd 1309
1489 +#define __NR_timerfd_create 1310
1490 +#define __NR_timerfd_settime 1311
1491 +#define __NR_timerfd_gettime 1312
1493 #define syscall(name, sym) \
1495 diff -urN -x CVS dietlibc-0.31/include/elf.h dietlibc/include/elf.h
1496 --- dietlibc-0.31/include/elf.h 2006-11-08 16:14:27.000000000 +0100
1497 +++ dietlibc/include/elf.h 2008-09-05 17:13:29.000000000 +0200
1498 @@ -2078,6 +2078,7 @@
1499 #define EF_ARM_EABI_UNKNOWN 0x00000000
1500 #define EF_ARM_EABI_VER1 0x01000000
1501 #define EF_ARM_EABI_VER2 0x02000000
1502 +#define EF_ARM_EABI_VER4 0x04000000
1504 /* Additional symbol types for Thumb */
1505 #define STT_ARM_TFUNC 0xd
1506 diff -urN -x CVS dietlibc-0.31/include/fcntl.h dietlibc/include/fcntl.h
1507 --- dietlibc-0.31/include/fcntl.h 2005-10-04 19:47:03.000000000 +0200
1508 +++ dietlibc/include/fcntl.h 2008-02-19 01:28:13.000000000 +0100
1509 @@ -624,9 +624,51 @@
1512 #if defined(_LINUX_SOURCE) || defined(_GNU_SOURCE)
1513 -ssize_t readahead(int fd, off64_t *offset, size_t count);
1514 +ssize_t readahead(int fd, off64_t *offset, size_t count) __THROW;
1518 +#define SPLICE_F_MOVE (0x01) /* move pages instead of copying */
1519 +#define SPLICE_F_NONBLOCK (0x02) /* don't block on the pipe splicing (but */
1520 + /* we may still block on the fd we splice */
1521 + /* from/to, of course */
1522 +#define SPLICE_F_MORE (0x04) /* expect more data */
1523 +#define SPLICE_F_GIFT (0x08) /* pages passed in are a gift */
1525 +long tee(int fd_in, int fd_out, size_t len, unsigned int flags) __THROW;
1527 +#include <sys/uio.h>
1529 +long vmsplice(int fd, const struct iovec *iov, unsigned long nr_segs, unsigned int flags) __THROW;
1530 +long splice(int fd_in, loff_t *off_in, int fd_out, loff_t *off_out, size_t len, unsigned int flags) __THROW;
1532 +int sync_file_range(int fd, off64_t offset, off64_t nbytes, unsigned int flags) __THROW;
1535 +#ifdef _ATFILE_SOURCE
1536 +#define AT_FDCWD -100 /* Special value used to indicate openat should use the current working directory. */
1537 +#define AT_SYMLINK_NOFOLLOW 0x100 /* Do not follow symbolic links. */
1538 +#define AT_REMOVEDIR 0x200 /* Remove directory instead of unlinking file. */
1539 +#define AT_SYMLINK_FOLLOW 0x400 /* Follow symbolic links. */
1541 +int openat(int dirfd, const char *pathname, int flags, ...);
1542 +int faccessat(int dirfd, const char *pathname, int mode, int flags);
1543 +int fchmodat(int dirfd, const char *pathname, mode_t mode, int flags);
1544 +int fchownat(int dirfd, const char *pathname, uid_t owner, gid_t group, int flags);
1545 +int fstatat(int dirfd, const char *pathname, struct stat *buf, int flags);
1546 +int futimesat(int dirfd, const char *pathname, const struct timeval times[2]);
1547 +int linkat(int olddirfd, const char *oldpath, int newdirfd, const char *newpath, int flags);
1548 +int mkdirat(int dirfd, const char *pathname, mode_t mode);
1549 +int mknodat(int dirfd, const char *pathname, mode_t mode, dev_t dev);
1550 +int readlinkat(int dirfd, const char *pathname, char *buf, size_t bufsiz);
1551 +int renameat(int olddirfd, const char *oldpath, int newdirfd, const char *newpath);
1552 +int symlinkat(const char *oldpath, int newdirfd, const char *newpath);
1553 +int unlinkat(int dirfd, const char *pathname, int flags);
1554 +int mkfifoat(int dirfd, const char *pathname, mode_t mode);
1555 +int utimensat(int dirfd, const char *pathname, struct timespec* t);
1562 diff -urN -x CVS dietlibc-0.31/include/linux/eventpoll.h dietlibc/include/linux/eventpoll.h
1563 --- dietlibc-0.31/include/linux/eventpoll.h 2003-08-19 18:58:18.000000000 +0200
1564 +++ dietlibc/include/linux/eventpoll.h 2008-02-20 01:45:11.000000000 +0100
1567 #include <sys/cdefs.h>
1568 #include <sys/ioctl.h>
1569 -#include <sys/poll.h>
1571 #include <sys/shm.h>
1574 diff -urN -x CVS dietlibc-0.31/include/netinet/in.h dietlibc/include/netinet/in.h
1575 --- dietlibc-0.31/include/netinet/in.h 2005-09-21 09:33:08.000000000 +0200
1576 +++ dietlibc/include/netinet/in.h 2008-02-19 01:28:13.000000000 +0100
1580 #define IPPORT_RESERVED 1024
1581 +#define INET_ADDRSTRLEN 16
1582 #define INET6_ADDRSTRLEN 46
1585 diff -urN -x CVS dietlibc-0.31/include/paths.h dietlibc/include/paths.h
1586 --- dietlibc-0.31/include/paths.h 2005-04-26 19:47:18.000000000 +0200
1587 +++ dietlibc/include/paths.h 2008-02-23 01:09:54.000000000 +0100
1590 #define _PATH_TMP "/tmp/"
1592 +#define _PATH_UTMP "/var/run/utmp"
1593 +#define _PATH_WTMP "/var/log/wtmp"
1595 +/* die, BSD, die!!! */
1596 +#define UTMP_FILE _PATH_UTMP
1597 +#define WTMP_FILE _PATH_WTMP
1599 +#define _PATH_UTMPX _PATH_UTMP
1600 +#define _PATH_WTMPX _PATH_WTMP
1603 diff -urN -x CVS dietlibc-0.31/include/poll.h dietlibc/include/poll.h
1604 --- dietlibc-0.31/include/poll.h 2003-03-14 17:42:28.000000000 +0100
1605 +++ dietlibc/include/poll.h 2008-02-20 01:47:08.000000000 +0100
1607 -/* ah, the sublime brokenness... susv3 defines poll.h, the Linux man
1608 - * page defines sys/poll.h; duh! */
1609 -#include <sys/poll.h>
1613 +#include <sys/cdefs.h>
1619 +#define POLLIN POLLIN
1621 +#define POLLPRI POLLPRI
1623 +#define POLLOUT POLLOUT
1625 +#define POLLERR POLLERR
1627 +#define POLLHUP POLLHUP
1628 + POLLNVAL = 0x0020,
1629 +#define POLLNVAL POLLNVAL
1630 + POLLRDNORM = 0x0040,
1631 +#define POLLRDNORM POLLRDNORM
1632 + POLLRDBAND = 0x0080,
1633 +#define POLLRDBAND POLLRDBAND
1634 + POLLWRBAND = 0x0200,
1635 +#define POLLWRBAND POLLWRBAND
1637 +#define POLLMSG POLLMSG
1638 +/* POLLREMOVE is for /dev/epoll (/dev/misc/eventpoll),
1639 + * a new event notification mechanism for 2.6 */
1640 + POLLREMOVE = 0x1000,
1641 +#define POLLREMOVE POLLREMOVE
1644 +#if defined(__sparc__) || defined (__mips__)
1645 +#define POLLWRNORM POLLOUT
1647 +#define POLLWRNORM 0x0100
1656 +typedef unsigned int nfds_t;
1658 +extern int poll(struct pollfd *ufds, nfds_t nfds, int timeout) __THROW;
1661 +#include <signal.h>
1662 +int ppoll(struct pollfd *fds, nfds_t nfds, const struct timespec *timeout, const sigset_t *sigmask) __THROW;
1667 +#endif /* _POLL_H */
1668 diff -urN -x CVS dietlibc-0.31/include/resolv.h dietlibc/include/resolv.h
1669 --- dietlibc-0.31/include/resolv.h 2006-07-05 08:27:18.000000000 +0200
1670 +++ dietlibc/include/resolv.h 2008-09-30 23:02:35.000000000 +0200
1672 int length, unsigned char **dnptrs, unsigned char *exp_dn,
1673 unsigned char **lastdnptr) __THROW;
1675 -int dn_expand(unsigned char *msg, unsigned char *eomorig,
1676 - unsigned char *comp_dn, unsigned char *exp_dn,
1677 +int dn_expand(const unsigned char *msg, const unsigned char *eomorig,
1678 + const unsigned char *comp_dn, unsigned char *exp_dn,
1679 int length) __THROW;
1681 void res_close(void) __THROW __attribute_dontuse__;
1682 diff -urN -x CVS dietlibc-0.31/include/sched.h dietlibc/include/sched.h
1683 --- dietlibc-0.31/include/sched.h 2003-08-19 18:58:17.000000000 +0200
1684 +++ dietlibc/include/sched.h 2008-02-19 01:28:13.000000000 +0100
1691 -#define CSIGNAL 0x000000ff /* signal mask to be sent at exit */
1692 -#define CLONE_VM 0x00000100 /* set if VM shared between processes */
1693 -#define CLONE_FS 0x00000200 /* set if fs info shared between processes */
1694 -#define CLONE_FILES 0x00000400 /* set if open files shared between processes */
1695 -#define CLONE_SIGHAND 0x00000800 /* set if signal handlers and blocked signals shared */
1696 -#define CLONE_PID 0x00001000 /* set if pid shared */
1697 -#define CLONE_PTRACE 0x00002000 /* set if we want to let tracing continue on the child too */
1698 -#define CLONE_VFORK 0x00004000 /* set if the parent wants the child to wake it up on mm_release */
1699 -#define CLONE_PARENT 0x00008000 /* set if we want to have the same parent as the cloner */
1700 -#define CLONE_THREAD 0x00010000 /* Same thread group? */
1702 -#define CLONE_SIGNAL (CLONE_SIGHAND | CLONE_THREAD)
1704 -int clone(void*(*fn)(void*),void*stack,int flags,void*arg);
1707 * Scheduling policies
1709 #define SCHED_OTHER 0
1711 int __sched_rr_get_interval(pid_t pid, struct timespec* tp);
1712 int sched_rr_get_interval(pid_t pid, struct timespec* tp);
1718 +#define CSIGNAL 0x000000ff /* signal mask to be sent at exit */
1719 +#define CLONE_VM 0x00000100 /* set if VM shared between processes */
1720 +#define CLONE_FS 0x00000200 /* set if fs info shared between processes */
1721 +#define CLONE_FILES 0x00000400 /* set if open files shared between processes */
1722 +#define CLONE_SIGHAND 0x00000800 /* set if signal handlers and blocked signals shared */
1723 +#define CLONE_PID 0x00001000 /* set if pid shared */
1724 +#define CLONE_PTRACE 0x00002000 /* set if we want to let tracing continue on the child too */
1725 +#define CLONE_VFORK 0x00004000 /* set if the parent wants the child to wake it up on mm_release */
1726 +#define CLONE_PARENT 0x00008000 /* set if we want to have the same parent as the cloner */
1727 +#define CLONE_THREAD 0x00010000 /* Same thread group? */
1729 +#define CLONE_SIGNAL (CLONE_SIGHAND | CLONE_THREAD)
1731 +int clone(void*(*fn)(void*),void*stack,int flags,void*arg);
1733 +int unshare(int flags);
1739 diff -urN -x CVS dietlibc-0.31/include/stdarg.h dietlibc/include/stdarg.h
1740 --- dietlibc-0.31/include/stdarg.h 2003-08-19 18:58:17.000000000 +0200
1741 +++ dietlibc/include/stdarg.h 2008-11-26 19:43:06.000000000 +0100
1743 #if (__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 96))
1745 typedef __builtin_va_list va_list;
1746 -#define va_start(v,l) __builtin_stdarg_start((v),l)
1747 +#define va_start(v,l) __builtin_va_start((v),(l))
1748 #define va_end __builtin_va_end
1749 #define va_arg __builtin_va_arg
1750 #define __va_copy(d,s) __builtin_va_copy((d),(s))
1751 diff -urN -x CVS dietlibc-0.31/include/stdlib.h dietlibc/include/stdlib.h
1752 --- dietlibc-0.31/include/stdlib.h 2006-07-04 05:33:02.000000000 +0200
1753 +++ dietlibc/include/stdlib.h 2007-09-20 20:51:18.000000000 +0200
1754 @@ -111,6 +111,11 @@
1758 +int mbtowc(wchar_t *pwc, const char *s, size_t n) __THROW;
1759 +int wctomb(char *s, wchar_t wc) __THROW;
1760 +size_t mbstowcs(wchar_t *dest, const char *src, size_t n) __THROW;
1761 +int mblen(const char* s,size_t n) __THROW __pure;
1766 diff -urN -x CVS dietlibc-0.31/include/sys/cdefs.h dietlibc/include/sys/cdefs.h
1767 --- dietlibc-0.31/include/sys/cdefs.h 2005-10-04 19:47:03.000000000 +0200
1768 +++ dietlibc/include/sys/cdefs.h 2008-05-09 06:36:56.000000000 +0200
1771 #define __builtin_expect(foo,bar) (foo)
1772 #define __expect(foo,bar) (foo)
1775 #define __expect(foo,bar) __builtin_expect((long)(foo),bar)
1776 #define __attribute_malloc__ __attribute__((__malloc__))
1778 # define __attribute_used __attribute__ ((__used__))
1780 # define __attribute_used
1781 +# define __warn_unused_result__
1786 #define __sentinel__
1789 +#if (__GNUC__ < 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ < 3))
1796 diff -urN -x CVS dietlibc-0.31/include/sys/epoll.h dietlibc/include/sys/epoll.h
1797 --- dietlibc-0.31/include/sys/epoll.h 2005-03-15 09:51:22.000000000 +0100
1798 +++ dietlibc/include/sys/epoll.h 2008-02-20 01:45:12.000000000 +0100
1801 #include <sys/cdefs.h>
1802 #include <sys/types.h>
1803 -#include <sys/poll.h>
1805 +#include <signal.h>
1810 int epoll_ctl(int epfd, int op, int fd, struct epoll_event* event) __THROW;
1811 int epoll_wait(int epfd, struct epoll_event *events, int maxevents,
1812 int timeout) __THROW;
1813 +int epoll_pwait(int epfd, struct epoll_event *events, int maxevents,
1814 + int timeout, const sigset_t* sigmask) __THROW;
1818 diff -urN -x CVS dietlibc-0.31/include/sys/inotify.h dietlibc/include/sys/inotify.h
1819 --- dietlibc-0.31/include/sys/inotify.h 2005-10-04 19:47:03.000000000 +0200
1820 +++ dietlibc/include/sys/inotify.h 2008-02-19 01:28:13.000000000 +0100
1822 #define _SYS_INOTIFY_H
1824 #include <sys/cdefs.h>
1825 +#include <inttypes.h>
1827 struct inotify_event {
1828 - __s32 wd; /* watch descriptor */
1829 - __u32 mask; /* watch mask */
1830 - __u32 cookie; /* cookie to synchronize two events */
1831 - __u32 len; /* length (including nulls) of name */
1832 - char name[0]; /* stub for possible name */
1833 + int32_t wd; /* watch descriptor */
1834 + uint32_t mask, /* watch mask */
1835 + cookie, /* cookie to synchronize two events */
1836 + len; /* length (including nulls) of name */
1837 + char name[0]; /* stub for possible name */
1840 /* the following are legal, implemented events that user-space can watch for */
1842 #define IN_MOVE (IN_MOVED_FROM | IN_MOVED_TO) /* moves */
1845 +#define IN_ONLYDIR 0x01000000 /* only watch the path if it is a directory */
1846 +#define IN_DONT_FOLLOW 0x02000000 /* don't follow a sym link */
1847 +#define IN_MASK_ADD 0x20000000 /* add to the mask of an already existing watch */
1848 #define IN_ISDIR 0x40000000 /* event occurred against dir */
1849 #define IN_ONESHOT 0x80000000 /* only send event once */
1851 diff -urN -x CVS dietlibc-0.31/include/sys/mman.h dietlibc/include/sys/mman.h
1852 --- dietlibc-0.31/include/sys/mman.h 2005-04-25 09:22:24.000000000 +0200
1853 +++ dietlibc/include/sys/mman.h 2007-10-09 01:15:27.000000000 +0200
1855 #define MAP_DENYWRITE 0x2000 /* ETXTBSY */
1856 #define MAP_EXECUTABLE 0x4000 /* mark it as an executable */
1857 #define MAP_LOCKED 0x8000 /* pages are locked */
1858 +#define MAP_POPULATE 0x10000
1859 #define MS_ASYNC 0x0001 /* sync memory asynchronously */
1860 #define MS_INVALIDATE 0x0002 /* invalidate mappings & caches */
1861 #define MS_SYNC 0x0004 /* synchronous memory sync */
1863 #define MAP_EXECUTABLE 0x4000 /* mark it as an executable */
1864 #define MAP_LOCKED 0x8000 /* lock the mapping */
1865 #define MAP_NORESERVE 0x10000 /* don't check for reservations */
1866 +#define MAP_POPULATE 0x20000
1867 #define MS_ASYNC 1 /* sync memory asynchronously */
1868 #define MS_SYNC 2 /* synchronous memory sync */
1869 #define MS_INVALIDATE 4 /* invalidate the caches */
1871 #define MAP_EXECUTABLE 0x1000 /* mark it as an executable */
1872 #define MAP_LOCKED 0x2000 /* pages are locked */
1873 #define MAP_NORESERVE 0x4000 /* don't check for reservations */
1874 +#define MAP_POPULATE 0x8000
1875 #define MS_ASYNC 1 /* sync memory asynchronously */
1876 #define MS_INVALIDATE 2 /* invalidate the caches */
1877 #define MS_SYNC 4 /* synchronous memory sync */
1879 #define MAP_GROWSDOWN 0x0100 /* stack-like segment */
1880 #define MAP_DENYWRITE 0x0800 /* ETXTBSY */
1881 #define MAP_EXECUTABLE 0x1000 /* mark it as an executable */
1882 +#define MAP_POPULATE 0x8000
1883 #define MS_ASYNC 1 /* sync memory asynchronously */
1884 #define MS_INVALIDATE 2 /* invalidate the caches */
1885 #define MS_SYNC 4 /* synchronous memory sync */
1887 #define MAP_EXECUTABLE 0x1000 /* mark it as an executable */
1888 #define MAP_LOCKED 0x2000 /* pages are locked */
1889 #define MAP_NORESERVE 0x4000 /* don't check for reservations */
1890 +#define MAP_POPULATE 0x8000
1891 #define MS_ASYNC 1 /* sync memory asynchronously */
1892 #define MS_INVALIDATE 2 /* invalidate the caches */
1893 #define MS_SYNC 4 /* synchronous memory sync */
1895 #define MAP_LOCKED 0x2000 /* pages are locked */
1896 #define MAP_NORESERVE 0x4000 /* don't check for reservations */
1897 #define MAP_GROWSDOWN 0x8000 /* stack-like segment */
1898 +#define MAP_POPULATE 0x10000
1900 #define MS_SYNC 1 /* synchronous memory sync */
1901 #define MS_ASYNC 2 /* sync memory asynchronously */
1903 #define MAP_EXECUTABLE 0x1000 /* mark it as an executable */
1904 #define MAP_LOCKED 0x2000 /* pages are locked */
1905 #define MAP_NORESERVE 0x4000 /* don't check for reservations */
1906 +#define MAP_POPULATE 0x8000
1907 #define MAP_WRITECOMBINED 0x10000 /* write-combine the area */
1908 #define MAP_NONCACHED 0x20000 /* don't cache the memory */
1910 diff -urN -x CVS dietlibc-0.31/include/sys/poll.h dietlibc/include/sys/poll.h
1911 --- dietlibc-0.31/include/sys/poll.h 2003-08-19 18:58:18.000000000 +0200
1912 +++ dietlibc/include/sys/poll.h 2008-02-20 01:45:12.000000000 +0100
1914 +/* ah, the sublime brokenness... susv3 defines poll.h, the Linux man
1915 + * page defines sys/poll.h; duh! */
1919 -#include <sys/cdefs.h>
1926 -#define POLLIN POLLIN
1928 -#define POLLPRI POLLPRI
1930 -#define POLLOUT POLLOUT
1932 -#define POLLERR POLLERR
1934 -#define POLLHUP POLLHUP
1935 - POLLNVAL = 0x0020,
1936 -#define POLLNVAL POLLNVAL
1937 - POLLRDNORM = 0x0040,
1938 -#define POLLRDNORM POLLRDNORM
1939 - POLLRDBAND = 0x0080,
1940 -#define POLLRDBAND POLLRDBAND
1941 - POLLWRBAND = 0x0200,
1942 -#define POLLWRBAND POLLWRBAND
1944 -#define POLLMSG POLLMSG
1945 -/* POLLREMOVE is for /dev/epoll (/dev/misc/eventpoll),
1946 - * a new event notification mechanism for 2.6 */
1947 - POLLREMOVE = 0x1000,
1948 -#define POLLREMOVE POLLREMOVE
1951 -#if defined(__sparc__) || defined (__mips__)
1952 -#define POLLWRNORM POLLOUT
1954 -#define POLLWRNORM 0x0100
1963 -extern int poll(struct pollfd *ufds, unsigned int nfds, int timeout) __THROW;
1967 -#endif /* _SYS_POLL_H */
1968 diff -urN -x CVS dietlibc-0.31/include/sys/signalfd.h dietlibc/include/sys/signalfd.h
1969 --- dietlibc-0.31/include/sys/signalfd.h 1970-01-01 01:00:00.000000000 +0100
1970 +++ dietlibc/include/sys/signalfd.h 2008-02-19 01:28:13.000000000 +0100
1972 +#ifndef _SYS_SIGNALFD_H
1973 +#define _SYS_SIGNALFD_H
1975 +#include <inttypes.h>
1977 +struct signalfd_siginfo {
1978 + uint32_t ssi_signo;
1979 + int32_t ssi_errno;
1985 + uint32_t ssi_band;
1986 + uint32_t ssi_overrun;
1987 + uint32_t ssi_trapno;
1988 + int32_t ssi_status;
1991 + uint64_t ssi_utime;
1992 + uint64_t ssi_stime;
1993 + uint64_t ssi_addr;
1994 + uint8_t __pad[48];
1999 +extern int signalfd (int __fd, const sigset_t *__mask, int __flags)
2000 + __nonnull ((2)) __THROW;
2005 diff -urN -x CVS dietlibc-0.31/include/sys/statvfs.h dietlibc/include/sys/statvfs.h
2006 --- dietlibc-0.31/include/sys/statvfs.h 1970-01-01 01:00:00.000000000 +0100
2007 +++ dietlibc/include/sys/statvfs.h 2008-08-06 02:28:13.000000000 +0200
2009 +#ifndef _SYS_STATVFS_H
2010 +#define _SYS_STATVFS_H
2012 +#include <sys/cdefs.h>
2013 +#include <sys/types.h>
2018 + unsigned long f_bsize; /* file system block size */
2019 + unsigned long f_frsize; /* fragment size */
2020 + fsblkcnt_t f_blocks; /* size of fs in f_frsize units */
2021 + fsblkcnt_t f_bfree; /* # free blocks */
2022 + fsblkcnt_t f_bavail; /* # free blocks for non-root */
2023 + fsfilcnt_t f_files; /* # inodes */
2024 + fsfilcnt_t f_ffree; /* # free inodes */
2025 + fsfilcnt_t f_favail; /* # free inodes for non-root */
2026 + unsigned long f_fsid; /* file system ID */
2027 + unsigned long f_flag; /* mount flags */
2028 + unsigned long f_namemax; /* maximum filename length */
2031 +int statvfs(const char *path, struct statvfs *buf) __THROW;
2032 +int fstatvfs(int fd, struct statvfs *buf) __THROW;
2034 +/* Definitions for the flag in `f_flag'. These definitions should be
2035 + kept in sync with the definitions in <sys/mount.h>. */
2038 + ST_RDONLY = 1, /* Mount read-only. */
2039 +#define ST_RDONLY ST_RDONLY
2040 + ST_NOSUID = 2 /* Ignore suid and sgid bits. */
2041 +#define ST_NOSUID ST_NOSUID
2044 + ST_NODEV = 4, /* Disallow access to device special files. */
2045 +# define ST_NODEV ST_NODEV
2046 + ST_NOEXEC = 8, /* Disallow program execution. */
2047 +# define ST_NOEXEC ST_NOEXEC
2048 + ST_SYNCHRONOUS = 16, /* Writes are synced at once. */
2049 +# define ST_SYNCHRONOUS ST_SYNCHRONOUS
2050 + ST_MANDLOCK = 64, /* Allow mandatory locks on an FS. */
2051 +# define ST_MANDLOCK ST_MANDLOCK
2052 + ST_WRITE = 128, /* Write on file/directory/symlink. */
2053 +# define ST_WRITE ST_WRITE
2054 + ST_APPEND = 256, /* Append-only file. */
2055 +# define ST_APPEND ST_APPEND
2056 + ST_IMMUTABLE = 512, /* Immutable file. */
2057 +# define ST_IMMUTABLE ST_IMMUTABLE
2058 + ST_NOATIME = 1024, /* Do not update access times. */
2059 +# define ST_NOATIME ST_NOATIME
2060 + ST_NODIRATIME = 2048, /* Do not update directory access times. */
2061 +# define ST_NODIRATIME ST_NODIRATIME
2062 + ST_RELATIME = 4096 /* Update atime relative to mtime/ctime. */
2063 +# define ST_RELATIME ST_RELATIME
2064 +#endif /* Use GNU. */
2070 diff -urN -x CVS dietlibc-0.31/include/sys/time.h dietlibc/include/sys/time.h
2071 --- dietlibc-0.31/include/sys/time.h 2005-09-21 09:33:08.000000000 +0200
2072 +++ dietlibc/include/sys/time.h 2008-09-04 11:25:51.000000000 +0200
2076 /* another wonderful BSD invention... :( */
2077 -/* note how subtly broken it is (doesn't work with <= or >=) */
2078 #define timercmp(a,b,CMP) (((a)->tv_sec == (b)->tv_sec) ? ((a)->tv_usec CMP (b)->tv_usec) : ((a)->tv_sec CMP (b)->tv_sec))
2079 #define timerclear(x) ((x)->tv_sec=(x)->tv_usec=0)
2080 #define timeradd(a,b,x) do { (x)->tv_sec=(a)->tv_sec+(b)->tv_sec; if (((x)->tv_usec=(a)->tv_usec+(b)->tv_usec)>=1000000) { ++(x)->tv_sec; (x)->tv_usec-=1000000; } } while (0)
2081 diff -urN -x CVS dietlibc-0.31/include/sys/timerfd.h dietlibc/include/sys/timerfd.h
2082 --- dietlibc-0.31/include/sys/timerfd.h 1970-01-01 01:00:00.000000000 +0100
2083 +++ dietlibc/include/sys/timerfd.h 2008-02-19 01:28:13.000000000 +0100
2085 +#ifndef _SYS_TIMERFD_H
2086 +#define _SYS_TIMERFD_H
2090 +enum { TFD_TIMER_ABSTIME = 1 };
2094 +int timerfd_create (clockid_t clock_id, int flags) __THROW;
2095 +int timerfd_settime (int ufd, int flags, const struct itimerspec *utmr, struct itimerspec *otmr) __THROW;
2096 +int timerfd_gettime (int ufd, struct itimerspec *otmr) __THROW;
2101 diff -urN -x CVS dietlibc-0.31/include/sys/types.h dietlibc/include/sys/types.h
2102 --- dietlibc-0.31/include/sys/types.h 2005-09-21 09:33:08.000000000 +0200
2103 +++ dietlibc/include/sys/types.h 2007-10-18 23:08:02.000000000 +0200
2105 clock ticks or CLOCKS_PER_SEC
2108 +typedef uint64_t fsblkcnt_t;
2109 +typedef uint64_t fsfilcnt_t;
2113 - Used for clock ID type in the clock and timer functions.
2115 - Used for file system block counts
2117 - Used for file system file counts
2119 Used to identify a thread attribute object.
2122 Used for read-write lock attributes.
2124 Used to identify a thread.
2126 - Used for timer ID returned by timer_create().
2129 #if defined(__alpha__) || defined(__ia64__) || defined(__sparc64__) || defined(__s390x__)
2130 diff -urN -x CVS dietlibc-0.31/include/utmp.h dietlibc/include/utmp.h
2131 --- dietlibc-0.31/include/utmp.h 2003-08-19 18:58:18.000000000 +0200
2132 +++ dietlibc/include/utmp.h 2008-02-23 01:09:54.000000000 +0100
2134 #include <sys/cdefs.h>
2135 #include <sys/types.h>
2142 #define UT_NAMESIZE 32
2143 #define UT_HOSTSIZE 256
2145 -#define _PATH_UTMP "/var/run/utmp"
2146 -#define _PATH_WTMP "/var/log/wtmp"
2148 -/* die, BSD, die!!! */
2149 -#define UTMP_FILE _PATH_UTMP
2150 -#define WTMP_FILE _PATH_WTMP
2153 /* The structure describing an entry in the database of
2157 char __unused[20]; /* Reserved for future use. */
2160 +#ifndef _UTMPX_H /* untmpx.h hasn't already defined these. */
2161 /* Values for the `ut_type' field of a `struct utmp'. */
2162 #define EMPTY 0 /* No valid user accounting information. */
2165 #define DEAD_PROCESS 8 /* Terminated process. */
2167 #define ACCOUNTING 9
2170 /* Tell the user that we have a modern system with UT_HOST, UT_PID,
2171 UT_TYPE, UT_ID and UT_TV fields. */
2172 diff -urN -x CVS dietlibc-0.31/include/utmpx.h dietlibc/include/utmpx.h
2173 --- dietlibc-0.31/include/utmpx.h 1970-01-01 01:00:00.000000000 +0100
2174 +++ dietlibc/include/utmpx.h 2008-02-23 01:09:54.000000000 +0100
2179 +#include <sys/cdefs.h>
2180 +#include <sys/types.h>
2181 +#include <sys/time.h>
2184 +/* For the getutmp{,x} functions we need the `struct utmp'. */
2189 +#define __UT_LINESIZE 32
2190 +#define __UT_NAMESIZE 32
2191 +#define __UT_HOSTSIZE 256
2195 +/* The structure describing the status of a terminated process. This
2196 + type is used in `struct utmpx below. */
2197 +struct __exit_status
2199 + short int e_termination; /* Process termination status. */
2200 + short int e_exit; /* Process exit status. */
2203 +/* The structure describing an entry in the user accounting database. */
2206 + short int ut_type; /* Type of login. */
2207 + pid_t ut_pid; /* Process ID of login process. */
2208 + char ut_line[__UT_LINESIZE]; /* Devicename. */
2209 + char ut_id[4]; /* Inittab ID. */
2210 + char ut_user[__UT_NAMESIZE]; /* Username. */
2211 + char ut_host[__UT_HOSTSIZE]; /* Hostname for remote login. */
2212 + struct __exit_status ut_exit; /* Exit status of a process marked
2213 + as DEAD_PROCESS. */
2214 +/* The ut_session and ut_tv fields must be the same size when compiled
2215 + 32- and 64-bit. This allows data files and shared memory to be
2216 + shared between 32- and 64-bit applications. */
2217 +#if __WORDSIZE == 64 && defined __WORDSIZE_COMPAT32
2218 + int32_t ut_session; /* Session ID, used for windowing. */
2221 + int32_t tv_sec; /* Seconds. */
2222 + int32_t tv_usec; /* Microseconds. */
2223 + } ut_tv; /* Time entry was made. */
2225 + long int ut_session; /* Session ID, used for windowing. */
2226 + struct timeval ut_tv; /* Time entry was made. */
2228 + int32_t ut_addr_v6[4]; /* Internet address of remote host. */
2229 + char __unused[20]; /* Reserved for future use. */
2232 +#ifndef _UTMP_H /* utmp.h hasn't already defined these. */
2233 +/* Values for the `ut_type' field of a `struct utmpx'. */
2234 +#define EMPTY 0 /* No valid user accounting information. */
2236 +#define RUN_LVL 1 /* The system's runlevel. */
2237 +#define BOOT_TIME 2 /* Time of system boot. */
2238 +#define NEW_TIME 3 /* Time after system clock changed. */
2239 +#define OLD_TIME 4 /* Time when system clock changed. */
2241 +#define INIT_PROCESS 5 /* Process spawned by the init process. */
2242 +#define LOGIN_PROCESS 6 /* Session leader of a logged in user. */
2243 +#define USER_PROCESS 7 /* Normal process. */
2244 +#define DEAD_PROCESS 8 /* Terminated process. */
2246 +#define ACCOUNTING 9
2249 +/* Apparently, these functions are all considered possible cancellation
2250 + * points, thus no __THROW */
2252 +struct utmpx *getutxent(void);
2253 +struct utmpx *getutxid(struct utmpx *ut);
2254 +struct utmpx *getutxline(struct utmpx *ut);
2256 +struct utmpx *pututxline(struct utmpx *ut);
2258 +void setutxent(void);
2259 +void endutxent(void);
2262 +void utmpxname (const char *file);
2263 +void updwtmpx (const char *wtmpx_file, const struct utmpx *utmpx);
2264 +void getutmp (const struct utmpx *utmpx, struct utmp *utmp);
2265 +void getutmpx (const struct utmp *utmp, struct utmpx *utmpx);
2271 diff -urN -x CVS dietlibc-0.31/include/wchar.h dietlibc/include/wchar.h
2272 --- dietlibc-0.31/include/wchar.h 2005-09-21 09:33:08.000000000 +0200
2273 +++ dietlibc/include/wchar.h 2007-09-09 04:11:18.000000000 +0200
2276 typedef unsigned int wint_t;
2278 -typedef unsigned long int wctype_t;
2279 +typedef int (*wctype_t)(wint_t) __THROW __attribute__((__const__));
2282 #define WCHAR_MIN (-2147483647 - 1)
2287 - unsigned long sofar;
2293 int wprintf(const wchar_t *__restrict__, ...);
2294 int wscanf(const wchar_t *__restrict__, ...);
2296 +#ifdef _XOPEN_SOURCE
2297 +int wcwidth(wchar_t c);
2303 diff -urN -x CVS dietlibc-0.31/lib/btowc.c dietlibc/lib/btowc.c
2304 --- dietlibc-0.31/lib/btowc.c 1970-01-01 01:00:00.000000000 +0100
2305 +++ dietlibc/lib/btowc.c 2007-09-09 04:11:18.000000000 +0200
2308 +#include "dietlocale.h"
2310 +wint_t btowc(int c) {
2311 + if (c==EOF) return WEOF;
2312 + switch (lc_ctype) {
2314 + return c>0xff?WEOF:1;
2316 + return c>0x7f?WEOF:1;
2320 diff -urN -x CVS dietlibc-0.31/lib/fstatvfs.c dietlibc/lib/fstatvfs.c
2321 --- dietlibc-0.31/lib/fstatvfs.c 1970-01-01 01:00:00.000000000 +0100
2322 +++ dietlibc/lib/fstatvfs.c 2007-10-18 23:08:02.000000000 +0200
2324 +#define _FILE_OFFSET_BITS 64
2325 +#include <sys/statvfs.h>
2326 +#include <sys/statfs.h>
2328 +extern void __statvfs_cvt(struct statfs* from,struct statvfs* to);
2330 +int fstatvfs(int fd, struct statvfs *sv) {
2332 + if (fstatfs(fd,&ss)==-1) return -1;
2333 + __statvfs_cvt(&ss,sv);
2336 diff -urN -x CVS dietlibc-0.31/lib/mblen.c dietlibc/lib/mblen.c
2337 --- dietlibc-0.31/lib/mblen.c 1970-01-01 01:00:00.000000000 +0100
2338 +++ dietlibc/lib/mblen.c 2007-09-20 20:51:18.000000000 +0200
2340 +#include <stdlib.h>
2343 +int mblen(const char* s,size_t n) {
2344 + return mbrlen(s,n,NULL);
2346 diff -urN -x CVS dietlibc-0.31/lib/mbrlen.c dietlibc/lib/mbrlen.c
2347 --- dietlibc-0.31/lib/mbrlen.c 1970-01-01 01:00:00.000000000 +0100
2348 +++ dietlibc/lib/mbrlen.c 2008-09-30 23:02:35.000000000 +0200
2353 +static mbstate_t internal;
2355 +size_t mbrlen(const char *s, size_t n, mbstate_t *ps) {
2356 + static mbstate_t internal;
2357 + return mbrtowc (NULL, s, n, ps ?: &internal);
2359 diff -urN -x CVS dietlibc-0.31/lib/mbrtowc.c dietlibc/lib/mbrtowc.c
2360 --- dietlibc-0.31/lib/mbrtowc.c 1970-01-01 01:00:00.000000000 +0100
2361 +++ dietlibc/lib/mbrtowc.c 2008-09-30 23:02:35.000000000 +0200
2363 +#include "dietlocale.h"
2367 +static mbstate_t internal;
2369 +size_t mbrtowc(wchar_t *pwc, const char *s, size_t n, mbstate_t *ps) {
2371 + if (!ps) ps=&internal;
2375 + return (size_t)-1;
2382 + for (i=0; i<n; ++i) {
2383 + unsigned char c=s[i];
2384 + switch (lc_ctype) {
2386 + if (pwc) { *pwc=c; ++pwc; }
2390 + /* we have an unfinished multibyte sequence */
2391 + if ((c&0xc0)!=0x80) {
2392 + /* expected a continuation, didn't get one */
2396 + return (size_t)-1;
2398 + ps->sofar=(ps->sofar << 6) + (c & 0x3f);
2399 + if (!--ps->count) {
2401 + if (pwc) { *pwc=ps->sofar; ++pwc; }
2406 + ps->count=0; ps->sofar=0;
2411 + if (c&0x80) { /* start of multibyte sequence? */
2412 + unsigned char x=c<<1;
2413 + unsigned char cnt=0;
2418 + if (!cnt || cnt>5) goto kaputt;
2419 + ps->sofar=x>>(cnt+1);
2430 diff -urN -x CVS dietlibc-0.31/lib/mbsinit.c dietlibc/lib/mbsinit.c
2431 --- dietlibc-0.31/lib/mbsinit.c 1970-01-01 01:00:00.000000000 +0100
2432 +++ dietlibc/lib/mbsinit.c 2007-09-09 03:37:54.000000000 +0200
2436 +int mbsinit(const mbstate_t* s) {
2437 + return (!s || s->sofar);
2439 diff -urN -x CVS dietlibc-0.31/lib/mbsrtowcs.c dietlibc/lib/mbsrtowcs.c
2440 --- dietlibc-0.31/lib/mbsrtowcs.c 1970-01-01 01:00:00.000000000 +0100
2441 +++ dietlibc/lib/mbsrtowcs.c 2008-09-30 23:13:46.000000000 +0200
2445 +size_t mbsrtowcs(wchar_t *dest, const char **src, size_t len, mbstate_t *ps) {
2446 + const char* orig=*src;
2448 + if (!dest) len=(size_t)-1;
2449 + for (i=0; i<len; ++i) {
2450 + size_t n=mbrtowc(dest?dest+i:0,*src,len,ps);
2451 + if (n==(size_t)-1) return -1;
2457 diff -urN -x CVS dietlibc-0.31/lib/mbstowcs.c dietlibc/lib/mbstowcs.c
2458 --- dietlibc-0.31/lib/mbstowcs.c 1970-01-01 01:00:00.000000000 +0100
2459 +++ dietlibc/lib/mbstowcs.c 2007-09-09 04:11:18.000000000 +0200
2461 +#include <stdlib.h>
2464 +size_t mbstowcs(wchar_t *dest, const char *src, size_t n) {
2465 + const char** s=&src;
2466 + return mbsrtowcs(dest,s,n,NULL);
2468 diff -urN -x CVS dietlibc-0.31/lib/mbtowc.c dietlibc/lib/mbtowc.c
2469 --- dietlibc-0.31/lib/mbtowc.c 1970-01-01 01:00:00.000000000 +0100
2470 +++ dietlibc/lib/mbtowc.c 2007-09-09 03:37:54.000000000 +0200
2472 +#include <stdlib.h>
2475 +int mbtowc(wchar_t *pwc, const char *s, size_t n) {
2476 + return mbrtowc(pwc,s,n,NULL);
2478 diff -urN -x CVS dietlibc-0.31/lib/memcpy.c dietlibc/lib/memcpy.c
2479 --- dietlibc-0.31/lib/memcpy.c 2003-12-21 13:06:36.000000000 +0100
2480 +++ dietlibc/lib/memcpy.c 2008-02-23 01:02:19.000000000 +0100
2483 if (n == (size_t) - 1)
2489 lx1 = (unsigned long *) dst;
2490 diff -urN -x CVS dietlibc-0.31/lib/signalfd.c dietlibc/lib/signalfd.c
2491 --- dietlibc-0.31/lib/signalfd.c 1970-01-01 01:00:00.000000000 +0100
2492 +++ dietlibc/lib/signalfd.c 2008-05-09 06:36:56.000000000 +0200
2494 +#include <signal.h>
2496 +#include <sys/signalfd.h>
2498 +extern int __signalfd(int fd,const sigset_t* mask,size_t nsig);
2500 +int signalfd(int fd,const sigset_t* mask,int flags) {
2501 + if (flags) { /* bizarre glibc bullshit */
2505 + return __signalfd(fd,mask,_NSIG/8);
2507 diff -urN -x CVS dietlibc-0.31/lib/stackgap.c dietlibc/lib/stackgap.c
2508 --- dietlibc-0.31/lib/stackgap.c 2007-08-24 23:19:33.000000000 +0200
2509 +++ dietlibc/lib/stackgap.c 2009-03-12 16:36:51.000000000 +0100
2512 #include <sys/time.h>
2513 #include <sys/tls.h>
2514 +#include <endian.h>
2516 #include "dietfeatures.h"
2518 extern int main(int argc,char* argv[],char* envp[]);
2520 extern unsigned long __guard;
2523 -#if defined(WANT_SSP) || defined(WANT_THREAD_SAFE)
2525 +/* __tdatasize is the size of the initialized thread local data section
2526 + * __tmemsize is the size of the complete thread local data section
2527 + * (including uninitialized data)
2528 + * __tdataptr is a pointer to the initialized thread local data section
2529 + * __tmemsize is already rounded up to meet alignment
2530 + * the final memory layout is [tdata] [tbss (zero)] [tcb] */
2531 +size_t __tdatasize, __tmemsize;
2534 +static void findtlsdata(long* auxvec) {
2535 +#if (__WORDSIZE == 64)
2542 + if (auxvec[0]==3) {
2543 + x=(void*)auxvec[1];
2547 + } /* if we don't find the entry, the kernel let us down */
2548 + if (!x) return; /* a kernel this old does not support thread local storage anyway */
2549 + if (x->p_type!=PT_PHDR) return; /* should start with PT_PHDR */
2550 + /* if it doesn't, assume there is no thread local storage */
2551 + n=x->p_memsz/sizeof(*x);
2552 + for (i=1; i<n; ++i)
2553 + if (x[i].p_type==PT_TLS) {
2554 + __tdataptr=(void*)x[i].p_vaddr;
2555 + __tdatasize=x[i].p_filesz;
2556 + __tmemsize=x[i].p_memsz;
2559 + /* if there is no PT_TLS section, there is no thread-local data, and
2560 + * we just leave the __t* variables zero */
2564 +#if defined(WANT_SSP) || defined(WANT_TLS)
2565 static tcbhead_t mainthread;
2567 -static void setup_tls(void) {
2568 - mainthread.tcb=&mainthread;
2569 - mainthread.self=&mainthread;
2570 +static void setup_tls(tcbhead_t* mainthread) {
2571 + mainthread->tcb=&mainthread;
2572 + mainthread->self=&mainthread;
2573 #if defined(WANT_SSP)
2574 - mainthread.stack_guard=__guard;
2575 + mainthread->stack_guard=__guard;
2578 #if defined(__x86_64__)
2580 - arch_prctl(ARCH_SET_FS, &mainthread);
2581 + arch_prctl(ARCH_SET_FS, mainthread);
2583 #elif defined(__i386__)
2585 static unsigned int sd[4];
2587 - sd[1]=(unsigned long int)&mainthread;
2588 + sd[1]=(unsigned long int)mainthread;
2589 sd[2]=0xfffff; /* 4 GB limit */
2590 sd[3]=0x51; /* bitfield, see struct user_desc in asm-i386/ldt.h */
2591 if (set_thread_area((struct user_desc*)(void*)&sd)==0) {
2595 #elif defined(__alpha__) || defined(__s390__)
2596 - __builtin_set_thread_pointer(&mainthread);
2597 + __builtin_set_thread_pointer(mainthread);
2598 #elif defined(__ia64__) || defined(__powerpc__)
2599 register tcbhead_t* __thread_self __asm__("r13");
2600 - __thread_self=&mainthread;
2601 + __thread_self=mainthread;
2602 #elif defined(__sparc__)
2603 register tcbhead_t* __thread_self __asm("%g7");
2604 - __thread_self=&mainthread;
2605 + __thread_self=mainthread;
2607 #warning "no idea how to enable TLS on this platform, edit lib/stackgap.c"
2612 +static void* find_rand(long* x) {
2615 + return (void*)x[1];
2621 int stackgap(int argc,char* argv[],char* envp[]);
2622 int stackgap(int argc,char* argv[],char* envp[]) {
2623 -#ifdef WANT_SSP_XOR
2624 - struct timeval tv;
2626 -#if defined(WANT_STACKGAP) || defined(WANT_SSP_URANDOM)
2627 - int fd=open("/dev/urandom",O_RDONLY);
2628 +#if defined(WANT_STACKGAP) || defined(WANT_SSP) || defined(WANT_TLS)
2629 + long* auxvec=(long*)envp;
2632 + while (*auxvec) ++auxvec; ++auxvec; /* skip envp to get to auxvec */
2633 #ifdef WANT_STACKGAP
2636 +#if defined(WANT_STACKGAP) || defined(WANT_SSP)
2639 + rand=find_rand(auxvec);
2642 + int fd=open("/dev/urandom",O_RDONLY);
2643 + read(fd,myrand,10);
2648 +#ifdef WANT_STACKGAP
2649 + s=*(unsigned short*)(rand+8);
2652 - read(fd,&__guard,sizeof(__guard));
2653 + __guard=*(unsigned long*)rand;
2656 #ifdef WANT_STACKGAP
2660 -#ifdef WANT_SSP_XOR
2661 - gettimeofday (&tv, NULL);
2662 - __guard ^= tv.tv_usec ^ tv.tv_sec ^ getpid();
2665 -#if defined(WANT_SSP) || defined(WANT_THREAD_SAFE)
2667 +#if defined(WANT_SSP) || defined(WANT_TLS)
2668 + findtlsdata(auxvec);
2669 + tlsdata=alloca(__tmemsize+sizeof(tcbhead_t));
2670 + memcpy(tlsdata,__tdataptr,__tdatasize);
2671 + memset(tlsdata+__tdatasize,0,__tmemsize-__tdatasize);
2672 + setup_tls((tcbhead_t*)(tlsdata+__tmemsize));
2674 return main(argc,argv,envp);
2676 diff -urN -x CVS dietlibc-0.31/lib/statvfs.c dietlibc/lib/statvfs.c
2677 --- dietlibc-0.31/lib/statvfs.c 1970-01-01 01:00:00.000000000 +0100
2678 +++ dietlibc/lib/statvfs.c 2008-05-09 06:36:56.000000000 +0200
2680 +#define _FILE_OFFSET_BITS 64
2681 +#include <sys/statvfs.h>
2682 +#include <sys/statfs.h>
2684 +extern void __statvfs_cvt(struct statfs* from,struct statvfs* to);
2686 +int statvfs(const char *path, struct statvfs *sv) {
2688 + if (statfs(path,&ss)==-1) return -1;
2689 + __statvfs_cvt(&ss,sv);
2693 diff -urN -x CVS dietlibc-0.31/lib/statvfs_cvt.c dietlibc/lib/statvfs_cvt.c
2694 --- dietlibc-0.31/lib/statvfs_cvt.c 1970-01-01 01:00:00.000000000 +0100
2695 +++ dietlibc/lib/statvfs_cvt.c 2007-10-18 23:08:02.000000000 +0200
2697 +#define _FILE_OFFSET_BITS 64
2698 +#include <sys/statvfs.h>
2699 +#include <sys/statfs.h>
2701 +void __statvfs_cvt(struct statfs* from,struct statvfs* to);
2703 +void __statvfs_cvt(struct statfs* from,struct statvfs* to) {
2704 + to->f_bsize=from->f_bsize;
2705 + to->f_frsize=from->f_frsize;
2706 + to->f_blocks=from->f_blocks;
2707 + to->f_bfree=from->f_bfree;
2708 + to->f_bavail=from->f_bavail;
2709 + to->f_files=from->f_files;
2710 + to->f_ffree=from->f_ffree;
2711 + to->f_favail=from->f_ffree;
2712 + to->f_fsid=from->f_fsid.__val[0];
2714 + to->f_namemax=from->f_namelen;
2716 diff -urN -x CVS dietlibc-0.31/lib/strcmp.c dietlibc/lib/strcmp.c
2717 --- dietlibc-0.31/lib/strcmp.c 2003-12-21 13:06:36.000000000 +0100
2718 +++ dietlibc/lib/strcmp.c 2008-02-19 01:28:13.000000000 +0100
2723 - if ((((l1 - MKW(0x1)) & ~l1) & MKW(0x80)) ||
2724 - ((((l2 - MKW(0x1)) & ~l2) & MKW(0x80))) || l1 != l2) {
2725 + if ((((l1 - MKW(0x1ul)) & ~l1) & MKW(0x80ul)) ||
2726 + ((((l2 - MKW(0x1ul)) & ~l2) & MKW(0x80ul))) || l1 != l2) {
2727 unsigned char c1, c2;
2733 if (!c1 || c1 != c2)
2742 diff -urN -x CVS dietlibc-0.31/lib/strcpy.c dietlibc/lib/strcpy.c
2743 --- dietlibc-0.31/lib/strcpy.c 2003-12-21 13:06:36.000000000 +0100
2744 +++ dietlibc/lib/strcpy.c 2008-02-19 01:28:13.000000000 +0100
2748 l = *(const unsigned long *) s2;
2749 - if (((l - MKW(0x1)) & ~l) & MKW(0x80)) {
2751 - while ((*s1++ = (l & 0xff))) l>>=8;
2752 + if (((l - MKW(0x1ul)) & ~l) & MKW(0x80ul)) {
2753 + while ((*s1++ = GFC(l))) INCSTR(l);
2756 *(unsigned long *) s1 = l;
2757 diff -urN -x CVS dietlibc-0.31/lib/strcspn.c dietlibc/lib/strcspn.c
2758 --- dietlibc-0.31/lib/strcspn.c 2001-01-09 18:57:43.000000000 +0100
2759 +++ dietlibc/lib/strcspn.c 2008-02-19 01:28:13.000000000 +0100
2761 size_t strcspn(const char *s, const char *reject)
2764 - int a=1,i,al=strlen(reject);
2765 + int i,al=strlen(reject);
2769 - for(i=0;(a)&&(i<al);i++)
2770 - if (*s==reject[i]) a=0;
2774 + for (i=0; reject[i]; ++i)
2775 + if (*s==reject[i]) return l;
2780 diff -urN -x CVS dietlibc-0.31/lib/strdup.c dietlibc/lib/strdup.c
2781 --- dietlibc-0.31/lib/strdup.c 2001-01-09 18:57:43.000000000 +0100
2782 +++ dietlibc/lib/strdup.c 2007-11-17 15:29:53.000000000 +0100
2786 char *strdup(const char *s) {
2787 - char *tmp=(char *)malloc(strlen(s)+1);
2788 + size_t l=strlen(s)+1;
2789 + char *tmp=(char *)malloc(l);
2793 + return memcpy(tmp,s,l);
2795 diff -urN -x CVS dietlibc-0.31/lib/strlen.c dietlibc/lib/strlen.c
2796 --- dietlibc-0.31/lib/strlen.c 2003-08-19 21:34:18.000000000 +0200
2797 +++ dietlibc/lib/strlen.c 2008-02-19 01:28:13.000000000 +0100
2800 #include "dietfeatures.h"
2802 +#include <stdint.h>
2804 #ifdef WANT_SMALL_STRING_ROUTINES
2805 size_t strlen(const char *s) {
2810 -static const unsigned long magic = 0x01010101;
2812 +#if __WORDSIZE == 64
2813 +typedef uint64_t word_t;
2814 +#elif __WORDSIZE == 32
2815 +typedef uint32_t word_t;
2817 +#error unsupported __WORDSIZE
2820 +static word_t const magic = (word_t)(0x0101010101010101ull);
2822 size_t strlen(const char *s)
2825 - unsigned long word;
2830 + if (__unlikely(!s)) return 0;
2832 /* Byte compare up until word boundary */
2833 - for (; ((unsigned long) t & 3); t++)
2834 + for (; ((unsigned long) t & (sizeof(magic)-1)); t++)
2835 if (!*t) return t - s;
2839 - word = *((unsigned long *) t); t += 4;
2840 + word = *((word_t const *) t); t += sizeof word;
2841 word = (word - magic) &~ word;
2842 word &= (magic << 7);
2843 } while (__likely(word == 0));
2845 -#if BYTE_ORDER == LITTLE_ENDIAN
2846 - /* word & 0x80808080 == word */
2847 - word = (word - 1) & (magic << 10);
2848 - word += (word << 8) + (word << 16);
2850 +#if __BYTE_ORDER == __LITTLE_ENDIAN
2852 + switch (sizeof(word)) {
2854 + /* word & 0x8080808080808080 == word */
2855 + word = (word - 1) & (magic << 8);
2856 + word += (word << 32);
2857 + word += (word << 16);
2858 + word += (word << 8);
2863 + /* word & 0x80808080 == word */
2864 + word = (word - 1) & (magic << 10);
2865 + word += (word << 8) + (word << 16);
2869 + default: { char exc[sizeof(word)==8]; (void)exc; }
2872 - if ((word & 0x80800000) == 0) {
2875 + mask = (magic << 7);
2877 + switch (sizeof(word)) {
2880 + if ((word & mask) == 0) {
2888 + if ((word & mask) == 0) {
2896 + if ((word & mask) == 0) {
2902 + default: { char exc[sizeof(word)==8]; (void)exc; }
2904 - if ((word & 0x80000000) == 0) t += 1;
2906 - return ((const char *) t) - 4 - s;
2907 + return t - sizeof(word) - s;
2910 diff -urN -x CVS dietlibc-0.31/lib/strpbrk.c dietlibc/lib/strpbrk.c
2911 --- dietlibc-0.31/lib/strpbrk.c 2001-01-09 18:57:43.000000000 +0100
2912 +++ dietlibc/lib/strpbrk.c 2008-02-19 01:28:13.000000000 +0100
2916 char *strpbrk(const char *s, const char *accept) {
2917 - register int i,l=strlen(accept);
2918 + register unsigned int i;
2920 - for (i=0; i<l; i++)
2921 + for (i=0; accept[i]; i++)
2922 if (*s == accept[i])
2925 diff -urN -x CVS dietlibc-0.31/lib/strspn.c dietlibc/lib/strspn.c
2926 --- dietlibc-0.31/lib/strspn.c 2001-01-09 18:57:43.000000000 +0100
2927 +++ dietlibc/lib/strspn.c 2008-02-19 01:28:13.000000000 +0100
2930 size_t strspn(const char *s, const char *accept)
2933 - int a=1,i,al=strlen(accept);
2939 - for(a=i=0;(!a)&&(i<al);i++)
2940 - if (*s==accept[i]) a=1;
2944 + for (a = accept; *a && *s != *a; a++);
2954 diff -urN -x CVS dietlibc-0.31/lib/strstr.c dietlibc/lib/strstr.c
2955 --- dietlibc-0.31/lib/strstr.c 2003-08-19 21:34:18.000000000 +0200
2956 +++ dietlibc/lib/strstr.c 2008-02-19 01:28:13.000000000 +0100
2958 char *strstr(const char *haystack, const char *needle) {
2959 size_t nl=strlen(needle);
2960 size_t hl=strlen(haystack);
2963 if (!nl) goto found;
2964 if (nl>hl) return 0;
2965 for (i=hl-nl+1; __likely(i); --i) {
2966 diff -urN -x CVS dietlibc-0.31/lib/timerfd_create.c dietlibc/lib/timerfd_create.c
2967 --- dietlibc-0.31/lib/timerfd_create.c 1970-01-01 01:00:00.000000000 +0100
2968 +++ dietlibc/lib/timerfd_create.c 2008-02-19 01:28:13.000000000 +0100
2970 +#include <sys/timerfd.h>
2972 +extern int __timerfd(int ufd, int clockid, int flags, const struct itimerspec *utmr);
2974 +int timerfd_create (clockid_t __clock_id, int __flags) {
2975 + return __timerfd(-1,__clock_id,__flags,0);
2977 diff -urN -x CVS dietlibc-0.31/lib/__v_printf.c dietlibc/lib/__v_printf.c
2978 --- dietlibc-0.31/lib/__v_printf.c 2007-05-17 07:00:42.000000000 +0200
2979 +++ dietlibc/lib/__v_printf.c 2008-02-19 01:28:13.000000000 +0100
2981 static const char pad_line[2][16]= { " ", "0000000000000000", };
2982 static int write_pad(unsigned int* dlen,struct arg_printf* fn, unsigned int len, int padwith) {
2984 - if ((int)len<0 || *dlen+len<len) return -1;
2985 + if ((int)len<=0) return 0;
2986 + if(*dlen+len<len) return -1;
2987 for (;len>15;len-=16,nr+=16) {
2988 A_WRITE(fn,pad_line[(padwith=='0')?1:0],16);
3000 #if __WORDSIZE == 64
3007 @@ -129,10 +129,18 @@
3011 - width=va_arg(arg_ptr,int);
3012 - if (width>MAX_WIDTH) return -1; /* width is unsiged, so this catches <0, too */
3016 + /* A negative field width is taken as a '-' flag followed by
3017 + * a positive field width
3020 + if ((tmp=va_arg(arg_ptr,int))<0) {
3024 + if ((width=(unsigned long)tmp)>MAX_WIDTH) return -1;
3032 if (flag_dot && width==0) width=preci;
3033 if (!flag_dot) preci=sz;
3034 - if (!flag_left) { /* do left-side padding */
3035 + if (!flag_left && padwith==' ') { /* do left-side padding with spaces */
3036 if (write_pad(&len,fn,width-preci,padwith))
3039 @@ -222,6 +230,10 @@
3040 B_WRITE(fn,sign,todo);
3043 + if (!flag_left && padwith!=' ') { /* do left-side padding with '0' */
3044 + if (write_pad(&len,fn,width-preci,padwith))
3047 /* do preci padding */
3048 if (write_pad(&len,fn,preci-sz,precpadwith))
3053 if (width<sz) width=sz;
3059 diff -urN -x CVS dietlibc-0.31/lib/__v_scanf.c dietlibc/lib/__v_scanf.c
3060 --- dietlibc-0.31/lib/__v_scanf.c 2005-04-10 15:59:32.000000000 +0200
3061 +++ dietlibc/lib/__v_scanf.c 2008-07-07 14:52:55.000000000 +0200
3067 if (!flag_discard) {
3069 pd=(double *)va_arg(arg_ptr,double*);
3070 diff -urN -x CVS dietlibc-0.31/lib/wcrtomb.c dietlibc/lib/wcrtomb.c
3071 --- dietlibc-0.31/lib/wcrtomb.c 1970-01-01 01:00:00.000000000 +0100
3072 +++ dietlibc/lib/wcrtomb.c 2007-09-09 03:37:54.000000000 +0200
3075 +#include "dietlocale.h"
3077 +static mbstate_t internal;
3079 +size_t wcrtomb(char *s, wchar_t wc, mbstate_t *ps) {
3080 + if (!ps) ps=&internal;
3081 + switch (lc_ctype) {
3087 + if (!s) return (wc>=0x80);
3089 + unsigned int bits,j,k;
3090 + if (wc>=0x04000000) { bits=30; *s=0xFC; j=6; } else
3091 + if (wc>=0x00200000) { bits=24; *s=0xF8; j=5; } else
3092 + if (wc>=0x00010000) { bits=18; *s=0xF0; j=4; } else
3093 + if (wc>=0x00000800) { bits=12; *s=0xE0; j=3; } else
3094 + if (wc>=0x00000080) { bits=6; *s=0xC0; j=2; } else
3095 + { *s=wc; return 1; }
3096 + *s |= (unsigned char)(wc>>bits);
3097 + for (k=1; k<j; ++k) {
3099 + s[k]=0x80+((wc>>bits)&0x3f);
3106 diff -urN -x CVS dietlibc-0.31/lib/wcsncat.c dietlibc/lib/wcsncat.c
3107 --- dietlibc-0.31/lib/wcsncat.c 1970-01-01 01:00:00.000000000 +0100
3108 +++ dietlibc/lib/wcsncat.c 2007-10-04 15:58:29.000000000 +0200
3112 +wchar_t* wcsncat(wchar_t *__restrict__ dest, const wchar_t *__restrict__ src,size_t n) {
3113 + wchar_t* orig=dest;
3115 + while (*dest) ++dest;
3116 + for (i=0; i<n && src[i]; ++i) dest[i]=src[i];
3120 diff -urN -x CVS dietlibc-0.31/lib/wcsncpy.c dietlibc/lib/wcsncpy.c
3121 --- dietlibc-0.31/lib/wcsncpy.c 1970-01-01 01:00:00.000000000 +0100
3122 +++ dietlibc/lib/wcsncpy.c 2007-10-04 15:58:29.000000000 +0200
3126 +wchar_t* wcsncpy(wchar_t *__restrict__ dest, const wchar_t *__restrict__ src,size_t n) {
3127 + wchar_t* orig=dest;
3128 + for (; dest<orig+n && (*dest=*src); ++src,++dest) ;
3129 + for (; dest<orig+n; ++dest) *dest=0;
3132 diff -urN -x CVS dietlibc-0.31/lib/wcsstr.c dietlibc/lib/wcsstr.c
3133 --- dietlibc-0.31/lib/wcsstr.c 1970-01-01 01:00:00.000000000 +0100
3134 +++ dietlibc/lib/wcsstr.c 2007-10-08 16:23:59.000000000 +0200
3138 +wchar_t *wcsstr(const wchar_t *haystack, const wchar_t *needle) {
3140 + for (i=0; haystack[i]; ++i) {
3141 + for (j=0; haystack[i+j]==needle[j]; ++j) ;
3142 + if (!needle[j]) return (wchar_t*)haystack+i;
3147 diff -urN -x CVS dietlibc-0.31/lib/wctomb.c dietlibc/lib/wctomb.c
3148 --- dietlibc-0.31/lib/wctomb.c 1970-01-01 01:00:00.000000000 +0100
3149 +++ dietlibc/lib/wctomb.c 2007-09-09 03:37:54.000000000 +0200
3151 +#include <stdlib.h>
3154 +int wctomb(char *pwc, wchar_t s) {
3155 + return wcrtomb(pwc,s,NULL);
3157 diff -urN -x CVS dietlibc-0.31/lib/wcwidth.c dietlibc/lib/wcwidth.c
3158 --- dietlibc-0.31/lib/wcwidth.c 1970-01-01 01:00:00.000000000 +0100
3159 +++ dietlibc/lib/wcwidth.c 2007-09-09 04:11:18.000000000 +0200
3161 +#define _XOPEN_SOURCE
3164 +int wcwidth(wchar_t c) {
3166 + if (c<' ') return -1;
3169 diff -urN -x CVS dietlibc-0.31/libcompat/getutmp.c dietlibc/libcompat/getutmp.c
3170 --- dietlibc-0.31/libcompat/getutmp.c 1970-01-01 01:00:00.000000000 +0100
3171 +++ dietlibc/libcompat/getutmp.c 2008-02-23 01:09:54.000000000 +0100
3173 +#include "dietfeatures.h"
3174 +#include <string.h>
3176 +#include "dietwarning.h"
3178 +#define _GNU_SOURCE
3182 +getutmp (const struct utmpx *utmpx, struct utmp *utmp)
3184 + memcpy (utmp, utmpx, sizeof(struct utmp));
3189 +getutmpx (const struct utmp *utmp, struct utmpx *utmpx)
3191 + memcpy (utmpx, utmp, sizeof(struct utmpx));
3195 +link_warning("getutmp","getutmp(): dietlibc utmp and utmpx structures are identical. If you actually require conversion, this it NOT the place to find it!");
3197 +link_warning("getutmpx","getutmpx(): dietlibc utmp and utmpx structures are identical. If you actually require conversion, this it NOT the place to find it!");
3198 diff -urN -x CVS dietlibc-0.31/libcompat/utmpxname.c dietlibc/libcompat/utmpxname.c
3199 --- dietlibc-0.31/libcompat/utmpxname.c 1970-01-01 01:00:00.000000000 +0100
3200 +++ dietlibc/libcompat/utmpxname.c 2008-02-23 01:09:54.000000000 +0100
3202 +#define _GNU_SOURCE
3205 +void __utmpxname (const char *file);
3208 +utmpxname (const char *file) {
3209 + __utmpxname (file);
3212 diff -urN -x CVS dietlibc-0.31/libcompat/wtxent.c dietlibc/libcompat/wtxent.c
3213 --- dietlibc-0.31/libcompat/wtxent.c 1970-01-01 01:00:00.000000000 +0100
3214 +++ dietlibc/libcompat/wtxent.c 2008-02-23 01:09:54.000000000 +0100
3216 +#include <unistd.h>
3218 +#include <string.h>
3220 +#define _GNU_SOURCE
3223 +void updwtmpx(const char *wtmpx_file, const struct utmpx *ut) {
3224 + int fd = open(wtmpx_file, O_WRONLY|O_APPEND);
3226 + fcntl (fd, F_SETFD, FD_CLOEXEC);
3227 + write(fd, ut, sizeof(struct utmpx));
3230 diff -urN -x CVS dietlibc-0.31/libcruft/dn_expand.c dietlibc/libcruft/dn_expand.c
3231 --- dietlibc-0.31/libcruft/dn_expand.c 2002-07-11 00:20:34.000000000 +0200
3232 +++ dietlibc/libcruft/dn_expand.c 2008-09-30 23:02:35.000000000 +0200
3234 #include <arpa/nameser.h>
3237 -extern int __dns_decodename(unsigned char *packet,unsigned int ofs,unsigned char *dest,
3238 - unsigned int maxlen,unsigned char* behindpacket);
3239 +extern int __dns_decodename(const unsigned char *packet,unsigned int ofs,unsigned char *dest,
3240 + unsigned int maxlen,const unsigned char* behindpacket);
3242 -int dn_expand(unsigned char *msg, unsigned char *eomorig, unsigned char *comp_dn, unsigned char *exp_dn, int length) {
3243 +int dn_expand(const unsigned char *msg, const unsigned char *eomorig, const unsigned char *comp_dn, unsigned char *exp_dn, int length) {
3244 return __dns_decodename(msg,comp_dn-msg,exp_dn,length,eomorig)-(comp_dn-msg);
3247 diff -urN -x CVS dietlibc-0.31/libcruft/dnscruft.c dietlibc/libcruft/dnscruft.c
3248 --- dietlibc-0.31/libcruft/dnscruft.c 2006-10-13 20:19:12.000000000 +0200
3249 +++ dietlibc/libcruft/dnscruft.c 2008-09-30 23:02:35.000000000 +0200
3251 void __dns_make_fd(void);
3252 void __dns_make_fd6(void);
3253 void __dns_readstartfiles(void);
3254 -int __dns_decodename(unsigned char *packet,unsigned int offset,unsigned char *dest,
3255 - unsigned int maxlen,unsigned char* behindpacket);
3256 +int __dns_decodename(const unsigned char *packet,unsigned int offset,unsigned char *dest,
3257 + unsigned int maxlen,const unsigned char* behindpacket);
3259 void __dns_make_fd(void) {
3261 @@ -148,11 +148,11 @@
3264 /* return length of decoded data or -1 */
3265 -int __dns_decodename(unsigned char *packet,unsigned int offset,unsigned char *dest,
3266 - unsigned int maxlen,unsigned char* behindpacket) {
3267 - unsigned char *tmp;
3268 - unsigned char *max=dest+maxlen;
3269 - unsigned char *after=packet+offset;
3270 +int __dns_decodename(const unsigned char *packet,unsigned int offset,unsigned char *dest,
3271 + unsigned int maxlen,const unsigned char* behindpacket) {
3272 + const unsigned char *tmp;
3273 + const unsigned char *max=dest+maxlen;
3274 + const unsigned char *after=packet+offset;
3276 for (tmp=after; maxlen>0&&*tmp; ) {
3277 if (tmp>=behindpacket) return -1;
3278 diff -urN -x CVS dietlibc-0.31/libcruft/getpagesize.c dietlibc/libcruft/getpagesize.c
3279 --- dietlibc-0.31/libcruft/getpagesize.c 2002-02-23 23:18:42.000000000 +0100
3280 +++ dietlibc/libcruft/getpagesize.c 2009-02-26 21:51:54.000000000 +0100
3282 #include <sys/types.h>
3283 #include <sys/ipc.h>
3284 #include <sys/shm.h>
3286 +#include <stdlib.h>
3289 #define PAGE_SIZE 4096
3292 size_t __libc_getpagesize(void);
3293 size_t __libc_getpagesize(void) {
3294 + long* x=(long*)environ;
3296 + while (*x) ++x; ++x; /* skip envp to get to auxvec */
3305 diff -urN -x CVS dietlibc-0.31/libcruft/res_query.c dietlibc/libcruft/res_query.c
3306 --- dietlibc-0.31/libcruft/res_query.c 2006-12-08 17:24:56.000000000 +0100
3307 +++ dietlibc/libcruft/res_query.c 2008-02-20 01:45:12.000000000 +0100
3311 #include <arpa/inet.h>
3312 -#include <sys/poll.h>
3316 #include <arpa/nameser.h>
3317 diff -urN -x CVS dietlibc-0.31/libcruft/setlocale.c dietlibc/libcruft/setlocale.c
3318 --- dietlibc-0.31/libcruft/setlocale.c 2006-04-04 05:10:40.000000000 +0200
3319 +++ dietlibc/libcruft/setlocale.c 2007-09-09 03:37:54.000000000 +0200
3321 #include "dietlocale.h"
3323 char *setlocale (int category, const char *locale) {
3325 if (locale && (category==LC_ALL || category==LC_CTYPE)) {
3330 x=getenv("LC_CTYPE");
3331 if (!x) x=getenv("LC_ALL");
3333 - if (strstr(x,".UTF-8") || strstr(x,".UTF8")) lc_ctype=CT_UTF8;
3337 + if (strstr(locale,".UTF-8") || strstr(locale,".UTF8")) lc_ctype=CT_UTF8;
3338 if (locale && (locale[0]!='C' || locale[1])) return 0;
3341 diff -urN -x CVS dietlibc-0.31/libdl/_dl_alloc.c dietlibc/libdl/_dl_alloc.c
3342 --- dietlibc-0.31/libdl/_dl_alloc.c 2005-10-07 21:33:34.000000000 +0200
3343 +++ dietlibc/libdl/_dl_alloc.c 2008-04-12 00:51:11.000000000 +0200
3346 #ifdef __DIET_LD_SO__
3347 tmp = (struct _dl_handle*)_dl_sys_mmap(0,at_pagesize,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANONYMOUS,-1,0);
3348 - m=at_pagesize/sizeof(struct _dl_handle);
3349 + m=DIV(at_pagesize,sizeof(struct _dl_handle));
3351 int ps=getpagesize();
3352 tmp = (struct _dl_handle*)mmap(0,ps,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANONYMOUS,-1,0);
3353 diff -urN -x CVS dietlibc-0.31/libdl/dlerror.c dietlibc/libdl/dlerror.c
3354 --- dietlibc-0.31/libdl/dlerror.c 2005-05-13 14:22:32.000000000 +0200
3355 +++ dietlibc/libdl/dlerror.c 2008-04-12 00:51:11.000000000 +0200
3360 - if (_dl_error>=(sizeof(_dl_error_msg)/sizeof(struct _dl_err_msg)))
3361 + if (_dl_error>=DIV(sizeof(_dl_error_msg),sizeof(struct _dl_err_msg)))
3364 if (_dl_error_location) {
3365 diff -urN -x CVS dietlibc-0.31/libdl/_dl_main.c dietlibc/libdl/_dl_main.c
3366 --- dietlibc-0.31/libdl/_dl_main.c 2006-11-16 11:04:00.000000000 +0100
3367 +++ dietlibc/libdl/_dl_main.c 2008-07-07 14:35:43.000000000 +0200
3369 " mov fp, #0 @ start new stack frame \n"
3370 " ldr a1, [sp], #4 @ argc \n"
3371 " mov a2, sp @ argv \n"
3372 +" mov sp, r4 @ restore stack pointer \n"
3373 " add a3, a2, a1, lsl #2 @ envp \n"
3374 " add a3, a3, #4 \n"
3375 /* PIC code startup */
3377 " add a4, a4, sl \n"
3380 -/* restore stack pointer */
3382 /* save program entry point */
3384 /* abi: agrument 1: global fini entry */
3385 @@ -371,20 +370,20 @@
3387 " stmdb sp!,{r0,r1,r2,r3} \n"
3389 -" swi #0x900090 @ mmap \n"
3390 +" swi #0x90005a @ mmap \n"
3391 " add sp, sp, #16 \n"
3393 ".type _dl_sys_munmap,function \n"
3394 "_dl_sys_munmap: \n"
3395 -" swi #0x900091 @ munmap \n"
3396 +" swi #0x90005b @ munmap \n"
3398 ".type _dl_sys_fstat,function \n"
3400 -" swi #0x900108 @ fstat \n"
3401 +" swi #0x90006c @ fstat \n"
3403 ".type _dl_sys_mprotect,function \n"
3404 "_dl_sys_mprotect: \n"
3405 -" swi #0x900125 @ mprotect \n"
3406 +" swi #0x90007d @ mprotect \n"
3409 ".type _dl_jump,function \n"
3410 @@ -689,6 +688,15 @@
3413 /* now reuse some unchanged sources */
3415 +#include "_dl_math.c"
3416 +#define MOD(a,b) _dl_mod(a,b)
3417 +#define DIV(a,b) _dl_div(a,b,NULL)
3419 +#define MOD(a,b) (a % b)
3420 +#define DIV(a,b) (a / b)
3423 #include "dlerror.c"
3424 #include "_dl_alloc.c"
3426 @@ -1092,7 +1100,7 @@
3428 pf(__FUNCTION__); pf(": try to relocate some values\n");
3430 - if (_dl_relocate(dh,rel,relsize/relent)) return 0;
3431 + if (_dl_relocate(dh,rel,DIV(relsize,relent))) return 0;
3434 /* do PTL / GOT relocation */
3435 diff -urN -x CVS dietlibc-0.31/libdl/_dl_math.c dietlibc/libdl/_dl_math.c
3436 --- dietlibc-0.31/libdl/_dl_math.c 1970-01-01 01:00:00.000000000 +0100
3437 +++ dietlibc/libdl/_dl_math.c 2008-04-12 00:51:11.000000000 +0200
3439 +static unsigned long _dl_div(
3440 + unsigned long num,
3441 + unsigned long den,
3442 + unsigned long * rem)
3444 + unsigned long quot = 0, qbit = 1;
3448 + /* Left-justify denominator and count shift */
3449 + while ((int) den >= 0) {
3466 +static unsigned long _dl_mod(unsigned long num, unsigned long den)
3468 + unsigned long rem;
3469 + _dl_div(num, den, &rem);
3472 diff -urN -x CVS dietlibc-0.31/libdl/dlsym.c dietlibc/libdl/dlsym.c
3473 --- dietlibc-0.31/libdl/dlsym.c 2006-11-16 11:04:00.000000000 +0100
3474 +++ dietlibc/libdl/dlsym.c 2008-04-12 00:51:11.000000000 +0200
3476 static void*_dlsym_elfhash(struct _dl_handle*dh,const unsigned char*symbol) {
3477 unsigned long*sym=0;
3478 unsigned int hash =elf_hash(symbol);
3479 - unsigned int bhash=hash%HASH_BUCKET_LEN(dh->hash_tab);
3480 + unsigned int bhash=MOD(hash, HASH_BUCKET_LEN(dh->hash_tab));
3481 unsigned int*chain=HASH_CHAIN(dh->hash_tab);
3482 unsigned char*name=(unsigned char*)dh->dyn_str_tab;
3483 unsigned int ind=HASH_BUCKET(dh->hash_tab)[bhash];
3485 unsigned long*sym=0;
3486 unsigned char*name=(unsigned char*)dh->dyn_str_tab;
3487 unsigned int hash =gnu_hash(symbol);
3488 - unsigned int bhash=hash%GNU_HASH_BUCKET_LEN(dh->gnu_hash_tab);
3489 + unsigned int bhash=MOD(hash, GNU_HASH_BUCKET_LEN(dh->hash_tab));
3490 unsigned int ind =GNU_HASH_BUCKET(dh->gnu_hash_tab,bhash);
3492 //pf(__FUNCTION__); pf(": bucket("); ph(bhash); pf(",\""); pf(symbol); pf("\")\n");
3493 diff -urN -x CVS dietlibc-0.31/libpthread/pthread_fputs.c dietlibc/libpthread/pthread_fputs.c
3494 --- dietlibc-0.31/libpthread/pthread_fputs.c 1970-01-01 01:00:00.000000000 +0100
3495 +++ dietlibc/libpthread/pthread_fputs.c 2008-05-09 06:36:56.000000000 +0200
3497 +#include <dietstdio.h>
3499 +int fputs(const char*s,FILE*stream) {
3500 + return fwrite(s,strlen(s),1,stream);
3502 diff -urN -x CVS dietlibc-0.31/libpthread/pthread_fread.c dietlibc/libpthread/pthread_fread.c
3503 --- dietlibc-0.31/libpthread/pthread_fread.c 1970-01-01 01:00:00.000000000 +0100
3504 +++ dietlibc/libpthread/pthread_fread.c 2008-05-09 06:36:56.000000000 +0200
3506 +#include <dietstdio.h>
3508 +size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream) {
3510 + pthread_mutex_lock(&stream->m);
3511 + tmp=fread_unlocked(ptr,size,nmemb,stream);
3512 + pthread_mutex_unlock(&stream->m);
3515 diff -urN -x CVS dietlibc-0.31/libpthread/pthread_fwrite.c dietlibc/libpthread/pthread_fwrite.c
3516 --- dietlibc-0.31/libpthread/pthread_fwrite.c 1970-01-01 01:00:00.000000000 +0100
3517 +++ dietlibc/libpthread/pthread_fwrite.c 2008-05-09 06:36:56.000000000 +0200
3519 +#include <dietstdio.h>
3521 +size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream) {
3523 + pthread_mutex_lock(&stream->m);
3524 + tmp=fwrite_unlocked(ptr,size,nmemb,stream);
3525 + pthread_mutex_unlock(&stream->m);
3528 diff -urN -x CVS dietlibc-0.31/libpthread/pthread_internal.c dietlibc/libpthread/pthread_internal.c
3529 --- dietlibc-0.31/libpthread/pthread_internal.c 2006-09-18 16:55:35.000000000 +0200
3530 +++ dietlibc/libpthread/pthread_internal.c 2008-02-20 01:45:12.000000000 +0100
3532 +#define _GNU_SOURCE
3535 #include <sys/wait.h>
3538 #include <sys/mman.h>
3540 -#include <sys/poll.h>
3543 #include <sys/resource.h>
3545 diff -urN -x CVS dietlibc-0.31/libregex/rx.c dietlibc/libregex/rx.c
3546 --- dietlibc-0.31/libregex/rx.c 2005-11-05 00:10:45.000000000 +0100
3547 +++ dietlibc/libregex/rx.c 2008-12-26 02:24:33.000000000 +0100
3552 +#if !defined(__x86_64__)
3553 +#undef WANT_REGEX_JIT
3557 * the idea is to build a parse tree, then do some poor man's OOP with a
3558 * generic matcher function call that is always that the start of each
3571 - enum { ILLEGAL, EMPTY, REGEX, BRACKET, ANY, LINESTART, LINEEND, WORDSTART, WORDEND, CHAR, } type;
3572 + enum { ILLEGAL, EMPTY, REGEX, BRACKET, ANY, LINESTART, LINEEND, WORDSTART, WORDEND, CHAR, STRING, BACKREF, } type;
3582 @@ -100,6 +110,30 @@
3584 static const char* parseregex(struct regex* r,const char* s,regex_t* rx);
3586 +static int matchatom_CHAR(void*__restrict__ x,const unsigned char*__restrict__ s,int ofs,struct __regex_t*__restrict__ preg,int plus,int eflags) {
3587 + register struct atom* a=(struct atom*)x;
3589 + printf("matching atom CHAR %c against \"%.20s\"\n",a->u.c,s);
3591 + if (*s!=a->u.c) return -1;
3593 + return ((struct atom*)(a->next))->m(a->next,(const char*)s+1,ofs+1,preg,plus+1,eflags);
3598 +static int matchatom_CHAR_ICASE(void*__restrict__ x,const unsigned char*__restrict__ s,int ofs,struct __regex_t*__restrict__ preg,int plus,int eflags) {
3599 + register struct atom* a=(struct atom*)x;
3601 + printf("matching atom CHAR_ICASE %c against \"%.20s\"\n",a->u.c,s);
3603 + if (tolower(*s)!=a->u.c) return -1;
3605 + return ((struct atom*)(a->next))->m(a->next,(const char*)s+1,ofs+1,preg,plus+1,eflags);
3610 static int matchatom(void*__restrict__ x,const unsigned char*__restrict__ s,int ofs,struct __regex_t*__restrict__ preg,int plus,int eflags) {
3611 register struct atom* a=(struct atom*)x;
3613 @@ -176,6 +210,30 @@
3615 if (((preg->cflags®_ICASE)?tolower(*s):*s)==a->u.c) goto match;
3618 + matchlen=a->u.s.len;
3620 + printf("matching atom STRING \"%.*s\" against \"%.20s\"\n",a->u.s.len,a->u.s.s,s);
3624 + if (preg->cflags®_ICASE) {
3625 + for (i=0; i<matchlen; ++i)
3626 + if (tolower(s[i]) != a->u.s.s[i]) return -1;
3628 + for (i=0; i<matchlen; ++i)
3629 + if (s[i] != a->u.s.s[i]) return -1;
3635 + matchlen=preg->l[(unsigned char)(a->u.c)].rm_eo-preg->l[(unsigned char)(a->u.c)].rm_so;
3637 + printf("matching atom BACKREF %d (\"%.*s\") against \"%.20s\"\n",a->u.c,matchlen,s-ofs+preg->l[a->u.c].rm_so,s);
3639 + if (memcmp(s-ofs+preg->l[(unsigned char)(a->u.c)].rm_so,s,matchlen)==0) goto match;
3644 @@ -226,10 +284,36 @@
3645 } else if (*s=='>') {
3648 + } else if (*s>='1' && *s<=(rx->brackets+'1') && ((rx->cflags®_EXTENDED)==0)) {
3653 + /* fall through */
3656 - a->u.c=rx->cflags®_ICASE?tolower(*s):*s;
3657 + if (rx->cflags®_ICASE) {
3658 + a->u.c=tolower(*s);
3659 + a->m=(matcher)matchatom_CHAR_ICASE;
3662 + a->m=(matcher)matchatom_CHAR;
3664 + /* optimization: if we have a run of CHAR, make it into a STRING */
3667 + for (i=1; s[i] && !strchr("(|)[.^$\\*+?{",s[i]); ++i) ;
3668 + if (!strchr("*+?{",s[i])) --i;
3670 + a->m=(matcher)matchatom;
3673 + if (!(a->u.s.s=malloc(i+1))) return s;
3674 + memcpy(a->u.s.s,s,i);
3683 if (b->m!=matchempty) {
3684 for (i=0; i<b->num-1; ++i) {
3685 if (b->p[i+1].min==1 && b->p[i+1].max==1)
3686 +/* shortcut: link directly to next atom if it's a piece with min=max=1 */
3687 piece_putnext(&b->p[i],&b->p[i+1].a);
3689 piece_putnext(&b->p[i],&b->p[i+1]);
3690 @@ -502,8 +587,10 @@
3694 - if (r->b[i].p[j].a.type==REGEX)
3695 - __regfree(&r->b[i].p[j].a.u.r);
3696 + if (r->b[i].p[j].a.type==REGEX)
3697 + __regfree(&r->b[i].p[j].a.u.r);
3698 + else if (r->b[i].p[j].a.type==STRING)
3699 + free(r->b[i].p[j].a.u.s.s);
3703 diff -urN -x CVS dietlibc-0.31/libstdio/fflush.c dietlibc/libstdio/fflush.c
3704 --- dietlibc-0.31/libstdio/fflush.c 2006-06-01 08:11:34.000000000 +0200
3705 +++ dietlibc/libstdio/fflush.c 2009-01-13 18:58:38.000000000 +0100
3709 int __fflush4(FILE *stream,int next) {
3710 - if (!__stdio_atexit) {
3711 + if (__unlikely(!__stdio_atexit)) {
3713 atexit(__stdio_flushall);
3715 - if ((stream->flags&BUFINPUT)!=next) {
3716 + if (__unlikely((stream->flags&BUFINPUT)!=next)) {
3717 int res=fflush_unlocked(stream);
3718 stream->flags=(stream->flags&~BUFINPUT)|next;
3720 diff -urN -x CVS dietlibc-0.31/libstdio/fgetc_unlocked.c dietlibc/libstdio/fgetc_unlocked.c
3721 --- dietlibc-0.31/libstdio/fgetc_unlocked.c 2005-09-21 09:33:08.000000000 +0200
3722 +++ dietlibc/libstdio/fgetc_unlocked.c 2009-02-26 21:51:54.000000000 +0100
3725 int fgetc_unlocked(FILE *stream) {
3727 - if (!(stream->flags&CANREAD)) goto kaputt;
3728 - if (stream->ungotten) {
3729 + if (__unlikely(!(stream->flags&CANREAD))) goto kaputt;
3730 + if (__unlikely(stream->ungotten)) {
3732 return stream->ungetbuf;
3734 - if (feof_unlocked(stream))
3736 + /* common case first */
3737 + if (__likely(stream->bm<stream->bs))
3738 + return (unsigned char)stream->buf[stream->bm++];
3740 + if (__unlikely(feof_unlocked(stream)))
3742 if (__fflush4(stream,BUFINPUT)) return EOF;
3743 - if (stream->bm>=stream->bs) {
3744 + if (__unlikely(stream->bm>=stream->bs)) {
3745 ssize_t len=__libc_read(stream->fd,stream->buf,stream->buflen);
3747 stream->flags|=EOFINDICATOR;
3748 diff -urN -x CVS dietlibc-0.31/libstdio/fgets.c dietlibc/libstdio/fgets.c
3749 --- dietlibc-0.31/libstdio/fgets.c 2003-11-11 19:39:51.000000000 +0100
3750 +++ dietlibc/libstdio/fgets.c 2009-01-13 18:58:38.000000000 +0100
3752 #include "dietstdio.h"
3754 char *fgets_unlocked(char *s, int size, FILE *stream) {
3757 - for (l=size; l>1;) {
3758 - register int c=fgetc_unlocked(stream);
3759 - if (c==EOF) break;
3763 - if (c=='\n') break;
3764 + for (l=0; l<size; ) {
3766 + if (l && __likely(stream->bm<stream->bs)) {
3767 + /* try common case first */
3768 + c=(unsigned char)stream->buf[stream->bm++];
3770 + c=fgetc_unlocked(stream);
3771 + if (__unlikely(c==EOF)) {
3784 - if (l==size || ferror_unlocked(stream))
3791 char*fgets(char*s,int size,FILE*stream) __attribute__((weak,alias("fgets_unlocked")));
3792 diff -urN -x CVS dietlibc-0.31/libstdio/fputc_unlocked.c dietlibc/libstdio/fputc_unlocked.c
3793 --- dietlibc-0.31/libstdio/fputc_unlocked.c 2003-11-11 19:27:41.000000000 +0100
3794 +++ dietlibc/libstdio/fputc_unlocked.c 2009-01-13 18:58:38.000000000 +0100
3798 int fputc_unlocked(int c, FILE *stream) {
3799 - if (!(stream->flags&CANWRITE) || __fflush4(stream,0)) {
3800 + if (!__likely(stream->flags&CANWRITE) || __fflush4(stream,0)) {
3802 stream->flags|=ERRORINDICATOR;
3805 - if (stream->bm>=stream->buflen-1)
3806 + if (__unlikely(stream->bm>=stream->buflen-1))
3807 if (fflush_unlocked(stream)) goto kaputt;
3808 if (stream->flags&NOBUF) {
3809 #if __BYTE_ORDER == __LITTLE_ENDIAN
3810 diff -urN -x CVS dietlibc-0.31/libstdio/fwrite.c dietlibc/libstdio/fwrite.c
3811 --- dietlibc-0.31/libstdio/fwrite.c 2005-09-21 09:33:08.000000000 +0200
3812 +++ dietlibc/libstdio/fwrite.c 2009-01-13 18:58:38.000000000 +0100
3815 size_t fwrite_unlocked(const void *ptr, size_t size, size_t nmemb, FILE *stream) {
3817 - unsigned long len=size*nmemb;
3819 - if (!(stream->flags&CANWRITE)) {
3820 + size_t len=size*nmemb;
3822 + if (!__likely(stream->flags&CANWRITE) || __fflush4(stream,0)) {
3824 stream->flags|=ERRORINDICATOR;
3827 if (!nmemb || len/nmemb!=size) return 0; /* check for integer overflow */
3828 - if (len>stream->buflen || (stream->flags&NOBUF)) {
3829 + if (__unlikely(len>stream->buflen || (stream->flags&NOBUF))) {
3830 if (fflush_unlocked(stream)) return 0;
3832 res=__libc_write(stream->fd,ptr,len);
3833 } while (res==-1 && errno==EINTR);
3835 - register const unsigned char *c=ptr;
3836 - for (i=len; i>0; --i,++c)
3837 - if (fputc_unlocked(*c,stream)) { res=len-i; goto abort; }
3838 + /* try to make the common case fast */
3839 + size_t todo=stream->buflen-stream->bm;
3840 + if (todo>len) todo=len;
3843 + if (stream->flags&BUFLINEWISE) {
3844 + for (i=0; i<todo; ++i) {
3845 + if ((stream->buf[stream->bm++]=((char*)ptr)[i])=='\n') {
3846 + if (fflush_unlocked(stream)) goto kaputt;
3850 + memcpy(stream->buf+stream->bm,ptr,todo);
3856 + for (i=done; i<len; ++i)
3857 + if (fputc_unlocked(((char*)ptr)[i],stream)) {
3864 diff -urN -x CVS dietlibc-0.31/libstdio/setvbuf.c dietlibc/libstdio/setvbuf.c
3865 --- dietlibc-0.31/libstdio/setvbuf.c 2006-06-01 08:11:34.000000000 +0200
3866 +++ dietlibc/libstdio/setvbuf.c 2007-10-09 01:15:27.000000000 +0200
3868 if (!(tmp=malloc(size))) return -1;
3869 if (!(stream->flags&STATICBUF)) free(stream->buf);
3871 - stream->flags &= ~STATICBUF;
3873 + stream->flags &= ~STATICBUF;
3874 stream->buflen=size;
3875 stream->bm=stream->bs=0;
3876 return set_flags(stream,flags);
3877 diff -urN -x CVS dietlibc-0.31/libugly/getaddrinfo.c dietlibc/libugly/getaddrinfo.c
3878 --- dietlibc-0.31/libugly/getaddrinfo.c 2007-03-26 05:06:59.000000000 +0200
3879 +++ dietlibc/libugly/getaddrinfo.c 2009-03-11 05:03:16.000000000 +0100
3880 @@ -102,11 +102,11 @@
3881 for (foo->ai.ai_socktype=SOCK_STREAM; ; foo->ai.ai_socktype=SOCK_DGRAM) {
3883 if (foo->ai.ai_socktype==SOCK_STREAM) { /* TCP */
3884 - if (hints->ai_socktype==SOCK_DGRAM) continue;
3885 + if (hints && hints->ai_socktype==SOCK_DGRAM) continue;
3886 foo->ai.ai_protocol=IPPROTO_TCP;
3889 - if (hints->ai_socktype==SOCK_STREAM) break;
3890 + if (hints && hints->ai_socktype==SOCK_STREAM) break;
3891 foo->ai.ai_protocol=IPPROTO_UDP;
3894 diff -urN -x CVS dietlibc-0.31/libugly/iswctype.c dietlibc/libugly/iswctype.c
3895 --- dietlibc-0.31/libugly/iswctype.c 1970-01-01 01:00:00.000000000 +0100
3896 +++ dietlibc/libugly/iswctype.c 2007-09-09 04:11:18.000000000 +0200
3898 +#include <wctype.h>
3899 +#include <string.h>
3901 +int iswctype(wint_t wc, wctype_t desc) {
3904 diff -urN -x CVS dietlibc-0.31/libugly/popen.c dietlibc/libugly/popen.c
3905 --- dietlibc-0.31/libugly/popen.c 2002-01-29 19:54:03.000000000 +0100
3906 +++ dietlibc/libugly/popen.c 2008-02-19 14:08:19.000000000 +0100
3909 if (pipe(pfd)<0) return 0;
3911 - if (!(f=fdopen(pfd[!fd0],type))) {
3912 + if ((!(f=fdopen(pfd[!fd0],type))) ||
3913 + ((pid=fork())<0)) {
3914 close(pfd[0]); /* malloc failed */
3918 - if ((pid=fork())<0) {
3923 if (!pid) { /* child */
3924 const char *argv[]={__sh,"-c",0,0};
3925 close(pfd[!fd0]); close(fd0);
3926 diff -urN -x CVS dietlibc-0.31/libugly/strptime.c dietlibc/libugly/strptime.c
3927 --- dietlibc-0.31/libugly/strptime.c 2007-08-03 22:58:33.000000000 +0200
3928 +++ dietlibc/libugly/strptime.c 2008-11-26 19:43:06.000000000 +0100
3929 @@ -134,6 +134,11 @@
3930 if (i==-1) return 0;
3934 + /* time zone. Not sure what I'm expected to do here. We'll just
3935 + * skip to the next whitespace */
3936 + while (*s!=' ' && *s!='\t') ++s;
3941 diff -urN -x CVS dietlibc-0.31/libugly/utent.c dietlibc/libugly/utent.c
3942 --- dietlibc-0.31/libugly/utent.c 2005-09-21 09:33:08.000000000 +0200
3943 +++ dietlibc/libugly/utent.c 2008-02-23 01:09:54.000000000 +0100
3946 static const char *utmp_file_name = _PATH_UTMP;
3948 +static off_t utmp_current = 0;
3950 static int lock_record(int type) {
3953 if (fd<0) fd = open(utmp_file_name,O_RDWR);
3954 if (fd<0) fd = open(utmp_file_name,O_RDONLY);
3955 fcntl (fd, F_SETFD, FD_CLOEXEC);
3956 - lseek(fd,0,SEEK_SET);
3957 + utmp_current = lseek(fd,0,SEEK_SET);
3966 struct utmp *getutent(void) {
3971 + utmp_current = lseek (fd, 0, SEEK_CUR);
3972 if (lock_record(F_RDLCK)) return 0;
3973 ret=read(fd, &getutent_tmp, sizeof(struct utmp));
3976 void pututline(struct utmp *ut) {
3979 + /* Seek to the current record before searching. */
3980 + lseek (fd, utmp_current, SEEK_SET);
3981 if ((tmp = getutid(ut))) {
3982 lseek(fd, - (off_t)sizeof(struct utmp), SEEK_CUR);
3983 if (lock_record(F_WRLCK)) return;
3984 write(fd, ut, sizeof(struct utmp));
3985 + utmp_current += sizeof(struct utmp);
3988 - lseek(fd, 0, SEEK_END);
3989 + utmp_current = lseek(fd, 0, SEEK_END);
3990 if (lock_record(F_WRLCK)) return;
3991 write(fd, ut, sizeof(struct utmp));
3993 diff -urN -x CVS dietlibc-0.31/libugly/__utmp_block_signals.c dietlibc/libugly/__utmp_block_signals.c
3994 --- dietlibc-0.31/libugly/__utmp_block_signals.c 1970-01-01 01:00:00.000000000 +0100
3995 +++ dietlibc/libugly/__utmp_block_signals.c 2008-02-23 01:09:54.000000000 +0100
3997 +#include <signal.h>
4000 + * Block a bunch of signals. Call with a sigset_t pointer into which
4001 + * the old signal set is placed. On error (which should never happen),
4002 + * returns NULL, otherwise returns oldset.
4005 +sigset_t *__utmp_block_signals (sigset_t *oldset);
4008 +__utmp_block_signals (sigset_t *oldset)
4010 + sigset_t blockset;
4012 + /* There are actually more signals to block than not, so just start
4013 + * with everything */
4014 + sigfillset (&blockset);
4016 + /* Don't try to block program error signals */
4018 + /* Unconditionally defined signals */
4019 + sigdelset (&blockset, SIGILL);
4020 + sigdelset (&blockset, SIGTRAP);
4021 + sigdelset (&blockset, SIGABRT);
4022 + sigdelset (&blockset, SIGIOT); /* Yeah, right */
4023 + sigdelset (&blockset, SIGFPE);
4024 + sigdelset (&blockset, SIGSEGV);
4026 + /* Others. FIXME - This list may need to be expanded. */
4028 + sigdelset (&blockset, SIGBUS);
4031 + sigdelset (&blockset, SIGEMT);
4034 + sigdelset (&blockset, SIGSYS);
4037 + if (sigprocmask (SIG_BLOCK, &blockset, oldset) < 0)
4038 + oldset = (sigset_t *)0;
4042 diff -urN -x CVS dietlibc-0.31/libugly/__utmp_io.c dietlibc/libugly/__utmp_io.c
4043 --- dietlibc-0.31/libugly/__utmp_io.c 1970-01-01 01:00:00.000000000 +0100
4044 +++ dietlibc/libugly/__utmp_io.c 2008-02-23 01:09:54.000000000 +0100
4046 +#include <unistd.h>
4050 +void *__utmp_io(int fd, void *ut, ssize_t len, off_t *offset, int type);
4052 +/* type: F_RDLCK or F_WRLCK */
4054 +__utmp_io(int fd, void *ut, ssize_t len, off_t *offset, int type) {
4059 + fl.l_whence = SEEK_CUR;
4065 + if (fcntl(fd, F_SETLKW, &fl)) return 0;
4066 + if (type == F_WRLCK) {
4067 + ret = write(fd, ut, len);
4070 + /* FIXME - where exactly should the offset point after a write? */
4071 + newoffset = lseek (fd, 0, SEEK_CUR);
4073 + newoffset = lseek (fd, 0, SEEK_CUR);
4074 + ret = read(fd, ut, len);
4078 + fl.l_start = -(len);
4079 + fl.l_type = F_UNLCK;
4081 + fcntl(fd, F_SETLK, &fl);
4083 + /* Arrrgh! There's no provision in the POSIX utmp spec for detecting errors.
4084 + * Stupidly update the offset. */
4086 + *offset = newoffset;
4093 diff -urN -x CVS dietlibc-0.31/libugly/utxent.c dietlibc/libugly/utxent.c
4094 --- dietlibc-0.31/libugly/utxent.c 1970-01-01 01:00:00.000000000 +0100
4095 +++ dietlibc/libugly/utxent.c 2008-02-23 01:09:54.000000000 +0100
4097 +#include <unistd.h>
4099 +#include <string.h>
4102 +#include <signal.h>
4104 +static const char *utmp_file_name = _PATH_UTMPX;
4105 +static int fd = -1;
4106 +static off_t utmp_current = 0;
4108 +/* Forward declaration for utmp common functions */
4109 +void *__utmp_io(int fd, void *ut, ssize_t len, off_t *offset, int type);
4110 +sigset_t *__utmp_block_signals (sigset_t *oldset);
4112 +/* See libcompat for utmpxname() */
4113 +void __utmpxname(const char *file); /* keep the compiler happy */
4114 +void __utmpxname(const char *file) {
4116 + utmp_file_name = file;
4118 + utmp_file_name = _PATH_UTMPX;
4122 + sigset_t oldset, *savedset;
4124 + savedset = __utmp_block_signals(&oldset);
4125 + if (fd<0) fd = open(utmp_file_name,O_RDWR);
4126 + if (fd<0) fd = open(utmp_file_name,O_RDONLY);
4127 + fcntl (fd, F_SETFD, FD_CLOEXEC);
4128 + utmp_current = lseek(fd,0,SEEK_SET);
4130 + sigprocmask (SIG_SETMASK, savedset, 0);
4139 +struct utmpx *getutxent(void) {
4140 + static struct utmpx getutent_tmp, *retval;
4142 + sigset_t oldset, *savedset;
4146 + if (fd<0) return 0;
4148 + savedset = __utmp_block_signals (&oldset);
4150 + retval = __utmp_io(fd, &getutent_tmp, sizeof(struct utmpx),
4151 + &utmp_current, F_RDLCK);
4154 + sigprocmask (SIG_SETMASK, savedset, 0);
4159 +struct utmpx *getutxid(struct utmpx *ut) {
4160 + struct utmpx *tmp;
4162 + while ((tmp = getutxent())) {
4163 + if (ut->ut_type && (ut->ut_type <= OLD_TIME)) {
4164 + if (ut->ut_type == tmp->ut_type) break;
4166 + if ((ut->ut_type >= INIT_PROCESS) && (ut->ut_type <= DEAD_PROCESS)) {
4167 + if (!strncmp(ut->ut_id,tmp->ut_id,4)) break;
4173 +struct utmpx *getutxline(struct utmpx *ut) {
4174 + struct utmpx *tmp;
4176 + while ((tmp = getutxent())) {
4177 + if ((tmp->ut_type == USER_PROCESS) || (tmp->ut_type == LOGIN_PROCESS)) {
4178 + if (!strncmp(ut->ut_line,tmp->ut_line,__UT_LINESIZE)) break;
4184 +struct utmpx *pututxline(struct utmpx *ut) {
4185 + struct utmpx *tmp, ut_copy, *retval = 0, *result;
4187 + ssize_t bytes_written;
4188 + sigset_t oldset, *savedset;
4190 + /* It's kosher to call this function with a pointer to our own static
4191 + * utmp structure, so work with a copy of "ut" */
4193 + memcpy (&ut_copy, ut, sizeof (struct utmpx));
4195 + savedset = __utmp_block_signals (&oldset);
4197 + /* Seek to the current record before searching. */
4198 + lseek (fd, utmp_current, SEEK_SET);
4199 + if ((tmp = getutxid(&ut_copy))) {
4200 + lseek(fd, - (off_t)sizeof(struct utmpx), SEEK_CUR);
4201 + result = __utmp_io (fd, &ut_copy, sizeof(struct utmpx),
4202 + &utmp_current, F_WRLCK);
4205 + utmp_current = lseek(fd, 0, SEEK_END);
4206 + result = __utmp_io (fd, &ut_copy, sizeof(struct utmpx),
4207 + &utmp_current, F_WRLCK);
4211 + sigprocmask (SIG_SETMASK, savedset, 0);
4217 + memcpy (ut, &ut_copy, sizeof (struct utmpx));
4222 diff -urN -x CVS dietlibc-0.31/libugly/wctype.c dietlibc/libugly/wctype.c
4223 --- dietlibc-0.31/libugly/wctype.c 1970-01-01 01:00:00.000000000 +0100
4224 +++ dietlibc/libugly/wctype.c 2007-09-09 04:11:18.000000000 +0200
4226 +#include <wctype.h>
4227 +#include <string.h>
4229 +struct { const char* name; wctype_t func; } types[]={
4230 + { "alnum", iswalnum },
4231 + { "alpha", iswalpha },
4232 + { "blank", iswblank },
4233 + { "cntrl", iswcntrl },
4234 + { "digit", iswdigit },
4235 + { "graph", iswgraph },
4236 + { "lower", iswlower },
4237 + { "print", iswprint },
4238 + { "punct", iswpunct },
4239 + { "space", iswspace },
4240 + { "upper", iswupper },
4241 + { "xdigit", iswxdigit },
4244 +wctype_t wctype(const char* name) {
4246 + for (i=0; i<sizeof(types)/sizeof(types[0]); ++i)
4247 + if (!strcmp(name,types[i].name)) return types[i].func;
4248 + return (wctype_t)0;
4250 diff -urN -x CVS dietlibc-0.31/libugly/wmemcmp.c dietlibc/libugly/wmemcmp.c
4251 --- dietlibc-0.31/libugly/wmemcmp.c 1970-01-01 01:00:00.000000000 +0100
4252 +++ dietlibc/libugly/wmemcmp.c 2007-10-01 19:22:56.000000000 +0200
4256 +int wmemcmp(const wchar_t *s1, const wchar_t *s2, size_t n) {
4258 + for (i=0; i<n; ++i) {
4259 + wint_t x=s1[i]-s2[i];
4264 diff -urN -x CVS dietlibc-0.31/libugly/wmemcpy.c dietlibc/libugly/wmemcpy.c
4265 --- dietlibc-0.31/libugly/wmemcpy.c 1970-01-01 01:00:00.000000000 +0100
4266 +++ dietlibc/libugly/wmemcpy.c 2007-10-01 19:22:56.000000000 +0200
4270 +wchar_t *wmemcpy(wchar_t *dest, const wchar_t *src, size_t n) {
4272 + for (i=0; i<n; ++i)
4276 diff -urN -x CVS dietlibc-0.31/libugly/wmemset.c dietlibc/libugly/wmemset.c
4277 --- dietlibc-0.31/libugly/wmemset.c 1970-01-01 01:00:00.000000000 +0100
4278 +++ dietlibc/libugly/wmemset.c 2007-10-01 19:22:56.000000000 +0200
4282 +wchar_t *wmemset(wchar_t *wcs, wchar_t wc, size_t n) {
4284 + for (i=0; i<n; ++i) wcs[i]=wc;
4287 diff -urN -x CVS dietlibc-0.31/Makefile dietlibc/Makefile
4288 --- dietlibc-0.31/Makefile 2007-02-08 15:40:20.000000000 +0100
4289 +++ dietlibc/Makefile 2008-05-09 06:36:56.000000000 +0200
4294 -CFLAGS += -Wall -W -Wchar-subscripts -Wmissing-prototypes -Wmissing-declarations -Wno-switch -Wno-unused -Wredundant-decls
4295 +CFLAGS += -W -Wall -Wextra -Wchar-subscripts -Wmissing-prototypes -Wmissing-declarations -Wno-switch -Wno-unused -Wredundant-decls
4301 $(CROSS)$(CC) -g -o t1 t.c
4303 -install: $(OBJDIR)/start.o $(OBJDIR)/dietlibc.a $(OBJDIR)/librpc.a $(OBJDIR)/liblatin1.a $(OBJDIR)/libcompat.a $(OBJDIR)/elftrunc $(OBJDIR)/diet-i
4304 +install-bin: $(OBJDIR)/start.o $(OBJDIR)/dietlibc.a $(OBJDIR)/librpc.a $(OBJDIR)/liblatin1.a $(OBJDIR)/libcompat.a $(OBJDIR)/elftrunc $(OBJDIR)/diet-i
4305 $(INSTALL) -d $(DESTDIR)$(ILIBDIR) $(DESTDIR)$(MAN1DIR) $(DESTDIR)$(BINDIR)
4306 $(INSTALL) $(OBJDIR)/start.o $(DESTDIR)$(ILIBDIR)/start.o
4307 $(INSTALL) -m 644 $(OBJDIR)/libm.a $(OBJDIR)/libpthread.a $(OBJDIR)/librpc.a \
4308 @@ -363,7 +363,12 @@
4309 -$(INSTALL) $(PICODIR)/diet-dyn-i $(DESTDIR)$(BINDIR)/diet-dyn
4311 $(INSTALL) -m 755 $(OBJDIR)/elftrunc $(OBJDIR)/dnsd $(DESTDIR)$(BINDIR)
4312 + $(INSTALL) -m 644 diet.1 $(DESTDIR)$(MAN1DIR)/diet.1
4315 -$(INSTALL) $(OBJDIR)/pstart.o $(OBJDIR)/libgmon.a $(OBJDIR)/dyn_start.o $(OBJDIR)/dyn_stop.o $(DESTDIR)$(ILIBDIR)
4318 -$(INSTALL) $(PICODIR)/libc.so $(DESTDIR)$(ILIBDIR)/libc.so
4319 -$(INSTALL) $(PICODIR)/libpthread.so $(DESTDIR)$(ILIBDIR)/libpthread.so
4320 -$(INSTALL) $(PICODIR)/libdl.so $(DESTDIR)$(ILIBDIR)/libdl.so
4321 @@ -372,10 +377,14 @@
4322 -$(INSTALL) $(PICODIR)/dyn_start.o $(DESTDIR)$(ILIBDIR)/dyn_dstart.o
4323 -$(INSTALL) $(PICODIR)/dyn_stop.o $(DESTDIR)$(ILIBDIR)/dyn_dstop.o
4324 -$(INSTALL) $(PICODIR)/dstart.o $(PICODIR)/dyn_so_start.o $(DESTDIR)$(ILIBDIR)
4325 - $(INSTALL) -m 644 diet.1 $(DESTDIR)$(MAN1DIR)/diet.1
4326 if test -f $(PICODIR)/libc.so -a ! -f $(DESTDIR)/etc/diet.ld.conf; then echo "$(ILIBDIR)" > $(DESTDIR)/etc/diet.ld.conf; fi
4329 for i in `find include -name \*.h`; do install -m 644 -D $$i $(DESTDIR)$(prefix)/$$i; done
4332 +install: install-bin install-profiling install-pic install-headers
4335 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
4336 rm -f $(DESTDIR)$(BINDIR)/diet $(DESTDIR)$(BINDIR)/diet-dyn
4337 diff -urN -x CVS dietlibc-0.31/mips/syscalls.h dietlibc/mips/syscalls.h
4338 --- dietlibc-0.31/mips/syscalls.h 2006-09-19 00:08:39.000000000 +0200
4339 +++ dietlibc/mips/syscalls.h 2008-09-30 23:02:35.000000000 +0200
4340 @@ -312,6 +312,21 @@
4341 #define __NR_tee (__NR_Linux + 306)
4342 #define __NR_vmsplice (__NR_Linux + 307)
4343 #define __NR_move_pages (__NR_Linux + 308)
4344 +#define __NR_set_robust_list (__NR_Linux + 272)
4345 +#define __NR_get_robust_list (__NR_Linux + 273)
4346 +#define __NR_kexec_load (__NR_Linux + 274)
4347 +#define __NR_getcpu (__NR_Linux + 275)
4348 +#define __NR_epoll_pwait (__NR_Linux + 276)
4349 +#define __NR_ioprio_set (__NR_Linux + 277)
4350 +#define __NR_ioprio_get (__NR_Linux + 278)
4351 +#define __NR_utimensat (__NR_Linux + 279)
4352 +#define __NR_signalfd (__NR_Linux + 280)
4353 +#define __NR_timerfd (__NR_Linux + 281)
4354 +#define __NR_eventfd (__NR_Linux + 282)
4355 +#define __NR_fallocate (__NR_Linux + 283)
4356 +#define __NR_timerfd_create (__NR_Linux + 284)
4357 +#define __NR_timerfd_gettime (__NR_Linux + 285)
4358 +#define __NR_timerfd_settime (__NR_Linux + 286)
4360 #define syscall_weak(name,wsym,sym) \
4362 diff -urN -x CVS dietlibc-0.31/parisc/mmap2.S dietlibc/parisc/mmap2.S
4363 --- dietlibc-0.31/parisc/mmap2.S 1970-01-01 01:00:00.000000000 +0100
4364 +++ dietlibc/parisc/mmap2.S 2008-11-03 04:13:35.000000000 +0100
4366 +#include "syscalls.h"
4369 +syscall6(mmap2,__mmap2)
4372 diff -urN -x CVS dietlibc-0.31/parisc/syscalls.h dietlibc/parisc/syscalls.h
4373 --- dietlibc-0.31/parisc/syscalls.h 2006-04-04 05:10:40.000000000 +0200
4374 +++ dietlibc/parisc/syscalls.h 2008-09-30 23:02:35.000000000 +0200
4375 @@ -277,8 +277,54 @@
4376 #define __NR_mbind (__NR_Linux + 260)
4377 #define __NR_get_mempolicy (__NR_Linux + 261)
4378 #define __NR_set_mempolicy (__NR_Linux + 262)
4379 +#define __NR_vserver (__NR_Linux + 263)
4380 +#define __NR_add_key (__NR_Linux + 264)
4381 +#define __NR_request_key (__NR_Linux + 265)
4382 +#define __NR_keyctl (__NR_Linux + 266)
4383 +#define __NR_ioprio_set (__NR_Linux + 267)
4384 +#define __NR_ioprio_get (__NR_Linux + 268)
4385 +#define __NR_inotify_init (__NR_Linux + 269)
4386 +#define __NR_inotify_add_watch (__NR_Linux + 270)
4387 +#define __NR_inotify_rm_watch (__NR_Linux + 271)
4388 +#define __NR_migrate_pages (__NR_Linux + 272)
4389 +#define __NR_pselect6 (__NR_Linux + 273)
4390 +#define __NR_ppoll (__NR_Linux + 274)
4391 +#define __NR_openat (__NR_Linux + 275)
4392 +#define __NR_mkdirat (__NR_Linux + 276)
4393 +#define __NR_mknodat (__NR_Linux + 277)
4394 +#define __NR_fchownat (__NR_Linux + 278)
4395 +#define __NR_futimesat (__NR_Linux + 279)
4396 +#define __NR_fstatat64 (__NR_Linux + 280)
4397 +#define __NR_unlinkat (__NR_Linux + 281)
4398 +#define __NR_renameat (__NR_Linux + 282)
4399 +#define __NR_linkat (__NR_Linux + 283)
4400 +#define __NR_symlinkat (__NR_Linux + 284)
4401 +#define __NR_readlinkat (__NR_Linux + 285)
4402 +#define __NR_fchmodat (__NR_Linux + 286)
4403 +#define __NR_faccessat (__NR_Linux + 287)
4404 +#define __NR_unshare (__NR_Linux + 288)
4405 +#define __NR_set_robust_list (__NR_Linux + 289)
4406 +#define __NR_get_robust_list (__NR_Linux + 290)
4407 +#define __NR_splice (__NR_Linux + 291)
4408 +#define __NR_sync_file_range (__NR_Linux + 292)
4409 +#define __NR_tee (__NR_Linux + 293)
4410 +#define __NR_vmsplice (__NR_Linux + 294)
4411 +#define __NR_move_pages (__NR_Linux + 295)
4412 +#define __NR_getcpu (__NR_Linux + 296)
4413 +#define __NR_epoll_pwait (__NR_Linux + 297)
4414 +#define __NR_statfs64 (__NR_Linux + 298)
4415 +#define __NR_fstatfs64 (__NR_Linux + 299)
4416 +#define __NR_kexec_load (__NR_Linux + 300)
4417 +#define __NR_utimensat (__NR_Linux + 301)
4418 +#define __NR_signalfd (__NR_Linux + 302)
4419 +#define __NR_timerfd (__NR_Linux + 303)
4420 +#define __NR_eventfd (__NR_Linux + 304)
4421 +#define __NR_fallocate (__NR_Linux + 305)
4422 +#define __NR_timerfd_create (__NR_Linux + 306)
4423 +#define __NR_timerfd_settime (__NR_Linux + 307)
4424 +#define __NR_timerfd_gettime (__NR_Linux + 308)
4426 -#define __NR_Linux_syscalls 263
4427 +#define __NR_Linux_syscalls (__NR_fallocate + 1)
4429 #define LINUX_GATEWAY_ADDR 0x100
4431 diff -urN -x CVS dietlibc-0.31/ppc/syscalls.h dietlibc/ppc/syscalls.h
4432 --- dietlibc-0.31/ppc/syscalls.h 2006-09-19 00:08:39.000000000 +0200
4433 +++ dietlibc/ppc/syscalls.h 2008-09-30 23:02:35.000000000 +0200
4434 @@ -299,6 +299,18 @@
4435 #define __NR_faccessat 298
4436 #define __NR_get_robust_list 299
4437 #define __NR_set_robust_list 300
4438 +#define __NR_move_pages 301
4439 +#define __NR_getcpu 302
4440 +#define __NR_epoll_pwait 303
4441 +#define __NR_utimensat 304
4442 +#define __NR_signalfd 305
4443 +#define __NR_timerfd 306
4444 +#define __NR_eventfd 307
4445 +#define __NR_sync_file_range2 308
4446 +#define __NR_fallocate 309
4447 +#define __NR_subpage_prot 310
4448 +#define __NR_timerfd_settime 311
4449 +#define __NR_timerfd_gettime 312
4452 #define syscall_weak(name,wsym,sym) \
4453 diff -urN -x CVS dietlibc-0.31/ppc64/syscalls.h dietlibc/ppc64/syscalls.h
4454 --- dietlibc-0.31/ppc64/syscalls.h 2006-09-19 00:08:39.000000000 +0200
4455 +++ dietlibc/ppc64/syscalls.h 2008-09-30 23:02:35.000000000 +0200
4456 @@ -299,7 +299,18 @@
4457 #define __NR_faccessat 298
4458 #define __NR_get_robust_list 299
4459 #define __NR_set_robust_list 300
4461 +#define __NR_move_pages 301
4462 +#define __NR_getcpu 302
4463 +#define __NR_epoll_pwait 303
4464 +#define __NR_utimensat 304
4465 +#define __NR_signalfd 305
4466 +#define __NR_timerfd 306
4467 +#define __NR_eventfd 307
4468 +#define __NR_sync_file_range2 308
4469 +#define __NR_fallocate 309
4470 +#define __NR_subpage_prot 310
4471 +#define __NR_timerfd_settime 311
4472 +#define __NR_timerfd_gettime 312
4475 #define __diet_proto_common(sym) \
4476 diff -urN -x CVS dietlibc-0.31/s390/syscalls.h dietlibc/s390/syscalls.h
4477 --- dietlibc-0.31/s390/syscalls.h 2006-09-19 00:08:39.000000000 +0200
4478 +++ dietlibc/s390/syscalls.h 2008-09-30 23:02:35.000000000 +0200
4479 @@ -293,6 +293,18 @@
4480 #define __NR_sync_file_range 307
4481 #define __NR_tee 308
4482 #define __NR_vmsplice 309
4483 +/* Number 310 is reserved for new sys_move_pages */
4484 +#define __NR_getcpu 311
4485 +#define __NR_epoll_pwait 312
4486 +#define __NR_utimes 313
4487 +#define __NR_fallocate 314
4488 +#define __NR_utimensat 315
4489 +#define __NR_signalfd 316
4490 +#define __NR_timerfd 317
4491 +#define __NR_eventfd 318
4492 +#define __NR_timerfd_create 319
4493 +#define __NR_timerfd_settime 320
4494 +#define __NR_timerfd_gettime 321
4497 #define syscall_weak(name,wsym,sym) \
4498 diff -urN -x CVS dietlibc-0.31/s390x/syscalls.h dietlibc/s390x/syscalls.h
4499 --- dietlibc-0.31/s390x/syscalls.h 2006-09-19 00:08:39.000000000 +0200
4500 +++ dietlibc/s390x/syscalls.h 2008-09-30 23:02:35.000000000 +0200
4501 @@ -293,6 +293,18 @@
4502 #define __NR_sync_file_range 307
4503 #define __NR_tee 308
4504 #define __NR_vmsplice 309
4505 +/* Number 310 is reserved for new sys_move_pages */
4506 +#define __NR_getcpu 311
4507 +#define __NR_epoll_pwait 312
4508 +#define __NR_utimes 313
4509 +#define __NR_fallocate 314
4510 +#define __NR_utimensat 315
4511 +#define __NR_signalfd 316
4512 +#define __NR_timerfd 317
4513 +#define __NR_eventfd 318
4514 +#define __NR_timerfd_create 319
4515 +#define __NR_timerfd_settime 320
4516 +#define __NR_timerfd_gettime 321
4520 diff -urN -x CVS dietlibc-0.31/sparc/syscalls.h dietlibc/sparc/syscalls.h
4521 --- dietlibc-0.31/sparc/syscalls.h 2006-09-19 00:08:39.000000000 +0200
4522 +++ dietlibc/sparc/syscalls.h 2008-09-30 23:02:35.000000000 +0200
4523 @@ -300,6 +300,21 @@
4524 #define __NR_unshare 299
4525 #define __NR_set_robust_list 300
4526 #define __NR_get_robust_list 301
4527 +#define __NR_migrate_pages 302
4528 +#define __NR_mbind 303
4529 +#define __NR_get_mempolicy 304
4530 +#define __NR_set_mempolicy 305
4531 +#define __NR_kexec_load 306
4532 +#define __NR_move_pages 307
4533 +#define __NR_getcpu 308
4534 +#define __NR_epoll_pwait 309
4535 +#define __NR_utimensat 310
4536 +#define __NR_signalfd 311
4537 +#define __NR_timerfd 312
4538 +#define __NR_eventfd 313
4539 +#define __NR_fallocate 314
4540 +#define __NR_timerfd_settime 315
4541 +#define __NR_timerfd_gettime 316
4543 #define syscall_weak(name,wsym,sym) \
4545 diff -urN -x CVS dietlibc-0.31/sparc64/syscalls.h dietlibc/sparc64/syscalls.h
4546 --- dietlibc-0.31/sparc64/syscalls.h 2006-09-19 00:08:39.000000000 +0200
4547 +++ dietlibc/sparc64/syscalls.h 2008-09-30 23:02:35.000000000 +0200
4548 @@ -299,6 +299,21 @@
4549 #define __NR_unshare 299
4550 #define __NR_set_robust_list 300
4551 #define __NR_get_robust_list 301
4552 +#define __NR_migrate_pages 302
4553 +#define __NR_mbind 303
4554 +#define __NR_get_mempolicy 304
4555 +#define __NR_set_mempolicy 305
4556 +#define __NR_kexec_load 306
4557 +#define __NR_move_pages 307
4558 +#define __NR_getcpu 308
4559 +#define __NR_epoll_pwait 309
4560 +#define __NR_utimensat 310
4561 +#define __NR_signalfd 311
4562 +#define __NR_timerfd 312
4563 +#define __NR_eventfd 313
4564 +#define __NR_fallocate 314
4565 +#define __NR_timerfd_settime 315
4566 +#define __NR_timerfd_gettime 316
4568 #define syscall_weak(name,wsym,sym) \
4570 diff -urN -x CVS dietlibc-0.31/syscalls.s/__signalfd.S dietlibc/syscalls.s/__signalfd.S
4571 --- dietlibc-0.31/syscalls.s/__signalfd.S 1970-01-01 01:00:00.000000000 +0100
4572 +++ dietlibc/syscalls.s/__signalfd.S 2008-02-19 01:28:13.000000000 +0100
4574 +#include "syscalls.h"
4576 +#ifdef __NR_signalfd
4577 +syscall(signalfd,__signalfd)
4579 diff -urN -x CVS dietlibc-0.31/syscalls.s/splice.S dietlibc/syscalls.s/splice.S
4580 --- dietlibc-0.31/syscalls.s/splice.S 1970-01-01 01:00:00.000000000 +0100
4581 +++ dietlibc/syscalls.s/splice.S 2008-02-19 01:28:13.000000000 +0100
4583 +#include "syscalls.h"
4586 +syscall(splice,splice)
4588 diff -urN -x CVS dietlibc-0.31/syscalls.s/tee.S dietlibc/syscalls.s/tee.S
4589 --- dietlibc-0.31/syscalls.s/tee.S 1970-01-01 01:00:00.000000000 +0100
4590 +++ dietlibc/syscalls.s/tee.S 2008-02-19 01:28:13.000000000 +0100
4592 +#include "syscalls.h"
4597 diff -urN -x CVS dietlibc-0.31/syscalls.s/timerfd.S dietlibc/syscalls.s/timerfd.S
4598 --- dietlibc-0.31/syscalls.s/timerfd.S 1970-01-01 01:00:00.000000000 +0100
4599 +++ dietlibc/syscalls.s/timerfd.S 2008-02-19 01:28:13.000000000 +0100
4601 +#include "syscalls.h"
4603 +#ifdef __NR_timerfd
4604 +syscall(timerfd,__timerfd)
4606 diff -urN -x CVS dietlibc-0.31/syscalls.s/vmsplice.S dietlibc/syscalls.s/vmsplice.S
4607 --- dietlibc-0.31/syscalls.s/vmsplice.S 1970-01-01 01:00:00.000000000 +0100
4608 +++ dietlibc/syscalls.s/vmsplice.S 2008-02-19 01:28:13.000000000 +0100
4610 +#include "syscalls.h"
4612 +#ifdef __NR_vmsplice
4613 +syscall(vmsplice,vmsplice)
4615 diff -urN -x CVS dietlibc-0.31/t.c dietlibc/t.c
4616 --- dietlibc-0.31/t.c 2005-10-08 23:11:32.000000000 +0200
4617 +++ dietlibc/t.c 2009-02-26 21:51:54.000000000 +0100
4618 @@ -105,12 +105,22 @@
4619 #define rdtscl(low) \
4620 __asm__ __volatile__ ("rdtsc" : "=a" (low) : : "edx")
4622 +#define malloc(x) ({typeof(x) y=x; (y<0 || (size_t)(y)!=y ? 0 : malloc(y));})
4624 int main(int argc,char *argv[]) {
4626 + char* a=malloc(-3);
4627 + char* b=malloc(0xffffffffull+1);
4628 + printf("%p %p\n",a,b);
4630 + printf("%u\n",getpagesize());
4635 stat("/tmp/nyt.html",&s);
4636 T=gmtime(&s.st_mtime);
4639 static struct mq_attr x;
4640 mqd_t a=mq_open("fnord",O_WRONLY|O_CREAT,0600,&x);
4641 diff -urN -x CVS dietlibc-0.31/test/Makefile dietlibc/test/Makefile
4642 --- dietlibc-0.31/test/Makefile 2003-12-15 14:07:42.000000000 +0100
4643 +++ dietlibc/test/Makefile 2008-02-23 01:02:19.000000000 +0100
4645 fputc ftw fwrite getaddrinfo getenv getgrnam gethostbyaddr gethostbyname \
4646 gethostbyname_r getmntent getopt getpass getpwnam getservbyname getservbyport getusershell \
4647 glob grent hasmntopt hello iconv if_nameindex ltostr malloc-debugger md5_testharness \
4648 -memccpy memchr memcmp memcpy memrchr memusage mktime mmap_test pipe printf printftest \
4649 +memccpy memchr memcmp memrchr memusage mktime mmap_test pipe printf printftest \
4650 protoent prototypes putenv pwent rand48 read1 readdir regex select sendfile servent siglist \
4651 -speed spent sprintf sscanf stdarg strcasecmp strcmp strlen strncat strncpy strptime strrchr \
4652 +speed spent sprintf sscanf stdarg strcasecmp strcmp strncat strncpy strptime strrchr \
4653 strstr strtol sysenter ungetc waitpid
4655 test: $(TESTPROGRAMS)
4656 diff -urN -x CVS dietlibc-0.31/test/mbrlen.c dietlibc/test/mbrlen.c
4657 --- dietlibc-0.31/test/mbrlen.c 1970-01-01 01:00:00.000000000 +0100
4658 +++ dietlibc/test/mbrlen.c 2008-09-30 23:02:35.000000000 +0200
4661 +#include <assert.h>
4663 +#include <locale.h>
4666 + static mbstate_t ps;
4667 + setlocale(LC_CTYPE,"de_DE.UTF8");
4668 + /* does it parse a single multibyte sequence OK? */
4669 + assert(mbrlen("\xc2\xa9",2,&ps)==2);
4670 + /* does it whine about an invalid sequence? */
4671 + assert(mbrlen("\xa9",1,&ps)==(size_t)-1);
4672 + /* does it accept a multibyte sequence in two parts? */
4673 + printf("%d\n",mbrlen("\xc2\xa9",1,&ps));
4674 + printf("%d\n",mbrlen("\xa9""fnord",6,&ps));
4675 + /* does it parse non-sequence stuff right? */
4676 + assert(mbrlen("f",1,&ps)==1);
4678 diff -urN -x CVS dietlibc-0.31/test/mbtowc.c dietlibc/test/mbtowc.c
4679 --- dietlibc-0.31/test/mbtowc.c 1970-01-01 01:00:00.000000000 +0100
4680 +++ dietlibc/test/mbtowc.c 2007-09-09 03:37:54.000000000 +0200
4682 +#include <stdlib.h>
4685 +#include <locale.h>
4686 +#include <string.h>
4687 +#include <assert.h>
4692 + char* c="fn\xc3\xb6rd";
4693 + size_t n=strlen(c);
4694 + setlocale(LC_CTYPE,"de_DE.UTF8");
4697 + assert(mbtowc(&ws,c,6)==1 && ws==102);
4698 + assert(mbtowc(&ws,c+1,5)==1 && ws==110);
4699 + assert(mbtowc(&ws,c+2,4)==2 && ws==246);
4700 + assert(mbtowc(&ws,c+4,2)==1 && ws==114);
4701 + assert(mbtowc(&ws,c+5,1)==1 && ws==100);
4702 + assert(mbtowc(&ws,c+6,1)==0);
4706 + assert(mbtowc(&ws,c,6)==1 && ws==102);
4707 + assert(mbtowc(&ws,c+1,5)==1 && ws==110);
4708 + assert(mbtowc(&ws,c+2,4)==(size_t)-1 && errno==EILSEQ);
4710 diff -urN -x CVS dietlibc-0.31/test/memcpy.c dietlibc/test/memcpy.c
4711 --- dietlibc-0.31/test/memcpy.c 2003-02-20 16:57:13.000000000 +0100
4712 +++ dietlibc/test/memcpy.c 1970-01-01 01:00:00.000000000 +0100
4714 -#include <string.h>
4715 -#include <assert.h>
4718 - char test[100]="blubber";
4719 - assert(memcpy(test,"blubber",8)==test);
4720 - assert(!memcmp(test,"blubber",8));
4721 - assert(memcpy(0,0,0)==0);
4722 - assert(memcpy(test,"foobar",3) && test[2]=='o');
4725 diff -urN -x CVS dietlibc-0.31/test/popen.c dietlibc/test/popen.c
4726 --- dietlibc-0.31/test/popen.c 1970-01-01 01:00:00.000000000 +0100
4727 +++ dietlibc/test/popen.c 2008-02-19 14:08:19.000000000 +0100
4730 +#include <assert.h>
4735 + assert(f=popen("/bin/echo foo","r"));
4736 + assert(fgets(buf,sizeof(buf),f));
4737 + assert(fclose(f)==0);
4738 + assert(!strcmp(buf,"foo\n"));
4740 diff -urN -x CVS dietlibc-0.31/test/printf.c dietlibc/test/printf.c
4741 --- dietlibc-0.31/test/printf.c 2004-01-07 16:06:48.000000000 +0100
4742 +++ dietlibc/test/printf.c 2008-02-19 01:28:13.000000000 +0100
4744 #define TEST_SNPRINTF(EXP,SZ, ...) \
4746 volatile char * args[] = { EXP, #SZ }; \
4747 - int test_sz=MIN((SZ),sizeof(EXP))-1; \
4748 + ssize_t test_sz=MIN((SZ),sizeof(EXP))-1; \
4751 rc=snprintf(buf+ALGN,(SZ),__VA_ARGS__); \
4752 TEST_CHECK(EXP, test_sz); \
4755 TEST("foobar", "%s", "foobar");
4756 TEST("01.23", "%05.2f", 1.23);
4757 + TEST("001.2", "%05.2g", 1.23);
4759 TEST("42", "%i", 42);
4760 TEST("", "%.0i", 0);
4761 @@ -111,6 +113,24 @@
4763 TEST("0x1", "%#x", 1);
4765 + TEST("abcX", "%2sX", "abc");
4766 + TEST("abcX", "%-2sX", "abc");
4768 + TEST("001234", "%.6u", 1234);
4769 + TEST("-001234", "%.6i", -1234);
4770 + TEST(" 1234", "%6u", 1234);
4771 + TEST(" -1234", "%6i", -1234);
4772 + TEST("001234", "%06u", 1234);
4773 + TEST("-01234", "%06i", -1234);
4774 + TEST("1234 ", "%-6u", 1234);
4775 + TEST("-1234 ", "%-6i", -1234);
4776 + TEST("1234", "%.6s", "1234");
4777 + TEST(" 1234", "%6s", "1234");
4778 + TEST("1234 ", "%-6s", "1234");
4779 + TEST(" 01234", "%6.5u", 1234);
4780 + TEST("-01234", "%6.5i", -1234);
4781 + TEST(" 1234", "%6.5s", "1234");
4784 setlocale(LC_ALL, "de_DE");
4786 diff -urN -x CVS dietlibc-0.31/test/regex.c dietlibc/test/regex.c
4787 --- dietlibc-0.31/test/regex.c 2005-07-23 01:08:15.000000000 +0200
4788 +++ dietlibc/test/regex.c 2008-12-22 01:25:54.000000000 +0100
4789 @@ -101,6 +101,17 @@
4790 assert(regexec(&r,"leitner@home.fefe.de",10,matches,0)==0);
4793 + assert(regcomp(&r,"^chello[0-9]*.chello.[a-z][a-z]$",REG_EXTENDED)==0);
4794 + assert(regexec(&r,"chello089078194199.chello.pl",10,matches,0)==0);
4797 + assert(regcomp(&r,"(satel.com|kievnet.com|dn|merlin.net|inetcom.com|zdn.gov|terabit.com|od|odessa|elencom.net|uz|syndicate.org|tvcom.net|dn|qt.net|b-net.com).ua",REG_EXTENDED|REG_ICASE|REG_NOSUB)==0);
4798 + assert(regexec(&r,"mail.b-net.com.ua",0,NULL,0)==0);
4801 + assert(regcomp(&r,"(foo)bar\\1",0)==0);
4802 + assert(regexec(&r,"foobarfoo",10,matches,0)==0);
4806 printf("regcomp %d\n",regcomp(&r,"\\.( ? ? ?\\.)*\\.",REG_EXTENDED|REG_NOSUB));
4807 diff -urN -x CVS dietlibc-0.31/test/runtests.sh dietlibc/test/runtests.sh
4808 --- dietlibc-0.31/test/runtests.sh 2003-12-15 14:07:42.000000000 +0100
4809 +++ dietlibc/test/runtests.sh 2008-02-23 01:02:19.000000000 +0100
4811 SUBDIRS="dirent inet stdio string stdlib time"
4813 -TESTPROGRAMS="adjtime argv atexit bsearch byteswap calloc confstr empty flush fputc ffs fnmatch ftw fwrite getaddrinfo getenv getdelim getgrnam gethostbyaddr gethostbyname gethostbyname_r getmntent getopt getpwnam getservbyname getservbyport getusershell glob grent hasmntopt hello iconv if_nameindex ltostr malloc-debugger md5_testharness memccpy memchr memcmp memcpy memrchr memusage mktime mmap_test pipe printf printftest protoent prototypes putenv pwent rand48 readdir regex select sendfile servent siglist speed spent sprintf sscanf stdarg strcasecmp strcmp strlen strncat strncpy strptime strrchr strstr strtol sysenter ungetc waitpid"
4814 +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"
4818 diff -urN -x CVS dietlibc-0.31/test/stdio/tst-fphex.c dietlibc/test/stdio/tst-fphex.c
4819 --- dietlibc-0.31/test/stdio/tst-fphex.c 2003-12-15 14:07:42.000000000 +0100
4820 +++ dietlibc/test/stdio/tst-fphex.c 2008-05-09 06:36:56.000000000 +0200
4822 int n = snprintf (buf, sizeof buf, t->fmt, t->value);
4823 if (n != strlen (t->expect) || strcmp (buf, t->expect) != 0)
4825 - printf ("%s\tExpected \"%s\" (%u)\n\tGot \"%s\" (%d, %u)\n",
4826 + printf ("%s\tExpected \"%s\" (%zu)\n\tGot \"%s\" (%d, %zu)\n",
4827 t->fmt, t->expect, strlen (t->expect), buf, n, strlen (buf));
4830 diff -urN -x CVS dietlibc-0.31/test/stdio/tst-fseek.c dietlibc/test/stdio/tst-fseek.c
4831 --- dietlibc-0.31/test/stdio/tst-fseek.c 2003-12-15 14:07:42.000000000 +0100
4832 +++ dietlibc/test/stdio/tst-fseek.c 2008-05-09 06:36:56.000000000 +0200
4834 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
4837 +#define _FILE_OFFSET_BITS 64
4842 const char outstr[] = "hello world!\n";
4843 char strbuf[sizeof outstr];
4845 - struct stat64 st1;
4846 - struct stat64 st2;
4851 tmpdir = getenv ("TMPDIR");
4855 /* Check the access time. */
4856 - if (fstat64 (fd, &st1) < 0)
4857 + if (fstat (fd, &st1) < 0)
4859 - printf ("%d: fstat64() before fseeko() failed\n\n", __LINE__);
4860 + printf ("%d: fstat() before fseeko() failed\n\n", __LINE__);
4868 - if (fstat64 (fd, &st2) < 0)
4869 + if (fstat (fd, &st2) < 0)
4871 - printf ("%d: fstat64() after fseeko() failed\n\n", __LINE__);
4872 + printf ("%d: fstat() after fseeko() failed\n\n", __LINE__);
4875 if (st1.st_ctime >= t)
4877 printf ("%d: fopen() failed\n\n", __LINE__);
4880 - else if (fstat64 (fileno (fp), &st1) < 0)
4881 + else if (fstat (fileno (fp), &st1) < 0)
4883 - printf ("%d: fstat64() before fseeko() failed\n\n", __LINE__);
4884 + printf ("%d: fstat() before fseeko() failed\n\n", __LINE__);
4887 else if (fseeko (fp, 0, SEEK_END) != 0)
4890 else if (ftello (fp) != st1.st_size)
4892 - printf ("%d: fstat64 st_size %zd ftello %zd\n", __LINE__,
4893 + printf ("%d: fstat st_size %zd ftello %zd\n", __LINE__,
4894 (size_t) st1.st_size, (size_t) ftello (fp));
4898 printf ("%d: fopen() failed\n\n", __LINE__);
4901 - else if (fstat64 (fileno (fp), &st1) < 0)
4902 + else if (fstat (fileno (fp), &st1) < 0)
4904 - printf ("%d: fstat64() before fgetc() failed\n\n", __LINE__);
4905 + printf ("%d: fstat() before fgetc() failed\n\n", __LINE__);
4908 else if (fgetc (fp) == EOF)
4911 else if (ftello (fp) != st1.st_size)
4913 - printf ("%d: fstat64 st_size %zd ftello %zd\n", __LINE__,
4914 + printf ("%d: fstat st_size %zd ftello %zd\n", __LINE__,
4915 (size_t) st1.st_size, (size_t) ftello (fp));
4918 diff -urN -x CVS dietlibc-0.31/test/strchr.c dietlibc/test/strchr.c
4919 --- dietlibc-0.31/test/strchr.c 1970-01-01 01:00:00.000000000 +0100
4920 +++ dietlibc/test/strchr.c 2007-12-05 23:41:01.000000000 +0100
4922 +#include <string.h>
4924 +#include <stdlib.h>
4925 +#include <assert.h>
4928 + char* p="/opt/diet/bin:/home/leitner/bin:/usr/local/bin:/opt/cross/bin:/usr/local/sbin:/usr/bin:/sbin:/bin:/usr/sbin:/usr/X11R6/bin:/opt/teTeX/bin:/opt/qt-4.3.2/bin:/opt/kde-3.5/bin:/usr/X11R7/bin:/opt/mono/bin";
4929 + assert(strchr(p,':')==p+13);
4930 + assert(strchr(p="fnord",'\0')==p+5);
4931 + assert(strchr(p,'r')==p+3);
4932 + assert(strchr(p,'x')==0);
4935 diff -urN -x CVS dietlibc-0.31/test/strcmp.c dietlibc/test/strcmp.c
4936 --- dietlibc-0.31/test/strcmp.c 2003-12-21 13:06:36.000000000 +0100
4937 +++ dietlibc/test/strcmp.c 2007-12-05 23:41:01.000000000 +0100
4940 char buf[100]="fnord";
4941 char buf2[100]="fnort";
4942 - if (strcmp(buf,buf)) die("strcmp say a != a");
4943 + if (strcmp(buf,buf)) die("strcmp said a != a");
4944 if (strcmp(buf,buf2)>=0) die("strcmp said fnord > fnort");
4945 if (strcmp(buf2,buf)<=0) die("strcmp said fnort < fnord");
4946 - if (strcmp(buf+1,buf2+1)>=0) die("unaligned strcmp is broken");
4947 - if (strcmp(buf+2,buf2+2)>=0) die("unaligned strcmp is broken");
4948 - if (strcmp(buf+3,buf2+3)>=0) die("unaligned strcmp is broken");
4949 + if (strcmp(buf+1,buf2+1)>=0) die("unaligned strcmp is broken 1");
4950 + if (strcmp(buf+2,buf2+2)>=0) die("unaligned strcmp is broken 2");
4951 + if (strcmp(buf+3,buf2+3)>=0) die("unaligned strcmp is broken 3");
4952 + if (strcmp("mäh","meh")<0) die("strcmp uses signed arithmetic");
4953 + if (strcmp("foo","foobar")>=0) die("prefix handling broken in strcmp 1");
4954 + if (strcmp("foobar","foo")<=0) die("prefix handling broken in strcmp 2");
4957 diff -urN -x CVS dietlibc-0.31/test/strcpy.c dietlibc/test/strcpy.c
4958 --- dietlibc-0.31/test/strcpy.c 1970-01-01 01:00:00.000000000 +0100
4959 +++ dietlibc/test/strcpy.c 2007-11-17 15:29:53.000000000 +0100
4961 +#include <string.h>
4962 +#include <assert.h>
4967 + for (i=0; i<100; ++i) {
4968 + memset(buf,'x',sizeof(buf));
4969 + strcpy(buf+i,"fnord");
4970 + assert(!strcmp(buf+i,"fnord"));
4971 + assert(buf[i+6]=='x');
4974 diff -urN -x CVS dietlibc-0.31/test/string/Makefile dietlibc/test/string/Makefile
4975 --- dietlibc-0.31/test/string/Makefile 2003-12-15 14:07:42.000000000 +0100
4976 +++ dietlibc/test/string/Makefile 2008-02-19 01:28:13.000000000 +0100
4981 +CFLAGS=-Wall -fno-builtin
4985 -TESTPROGRAMS=memccpy memchr memcmp memcpy memrchr strcasecmp strcmp strlen strncat strncpy strrchr strstr
4986 +TESTPROGRAMS=memccpy memchr memcmp memcpy memrchr strcasecmp strcmp strlen strncat strncpy strrchr strstr \
4987 +strspn strcspn strpbrk
4989 stringtest: $(TESTPROGRAMS)
4991 diff -urN -x CVS dietlibc-0.31/test/string/memcpy.c dietlibc/test/string/memcpy.c
4992 --- dietlibc-0.31/test/string/memcpy.c 2003-12-15 14:07:42.000000000 +0100
4993 +++ dietlibc/test/string/memcpy.c 2008-02-23 01:02:19.000000000 +0100
4997 +#include <sys/param.h>
4999 +#define WO (__WORDSIZE/8)
5002 + size_t const LENS[] = {
5003 + 1, 2, 3, 4, 5, 6, 7, 8,
5004 + WO -3, WO -2, WO -1, WO, WO +1, WO +2, WO +3, WO +4,
5005 + WO*2-3, WO*2-2, WO*2-1, WO*2, WO*2+1, WO*2+2, WO*2+3, WO*2+4,
5006 + WO*3-3, WO*3-2, WO*3-1, WO*3, WO*3+1, WO*3+2, WO*3+3, WO*3+4,
5010 + size_t const *len;
5011 char test[100]="blubber";
5013 assert(memcpy(test,"blubber",8)==test);
5014 assert(!memcmp(test,"blubber",8));
5015 assert(memcpy(0,0,0)==0);
5016 assert(memcpy(test,"foobar",3) && test[2]=='o');
5018 + /* test all possible alignments of src and destination in combination with
5019 + * some interesting lengths */
5020 + for (len=LENS+0; *len!=(size_t)(-1); ++len) {
5021 + unsigned char src[WO * 5];
5023 + for (i=0; i<*len + WO; ++i)
5026 + for (i=MIN(WO,*len); i>0;) {
5029 + for (j=MIN(WO,*len); j>0;) {
5030 + unsigned char dst[WO * 5];
5034 + for (k=0; k<*len; ++k)
5035 + dst[j+k]=src[i+k]+1;
5037 + assert(memcpy(dst+j, src+i, *len)==dst+j);
5039 + for (k=0; k<*len; ++k)
5040 + assert(dst[j+k]==src[i+k]);
5047 diff -urN -x CVS dietlibc-0.31/test/string/runtests.sh dietlibc/test/string/runtests.sh
5048 --- dietlibc-0.31/test/string/runtests.sh 2003-12-15 14:07:42.000000000 +0100
5049 +++ dietlibc/test/string/runtests.sh 2008-02-19 01:28:13.000000000 +0100
5053 -TESTPROGRAMS="memccpy memchr memcmp memcpy memrchr strcasecmp strcmp strlen strncat strncpy strrchr strstr"
5054 +TESTPROGRAMS="memccpy memchr memcmp memcpy memrchr strcasecmp strcmp strlen strncat strncpy strrchr strstr strspn strcspn strpbrk"
5056 for p in $TESTPROGRAMS; do
5057 echo "---";echo testing $p;echo "---"
5058 diff -urN -x CVS dietlibc-0.31/test/string/strcspn.c dietlibc/test/string/strcspn.c
5059 --- dietlibc-0.31/test/string/strcspn.c 1970-01-01 01:00:00.000000000 +0100
5060 +++ dietlibc/test/string/strcspn.c 2008-02-19 01:28:13.000000000 +0100
5063 +#include <string.h>
5064 +#include <assert.h>
5067 + assert(strcspn("foo:bar:",":")==3);
5068 + assert(strcspn("foo:bar:","=of")==0);
5071 diff -urN -x CVS dietlibc-0.31/test/string/strlen.c dietlibc/test/string/strlen.c
5072 --- dietlibc-0.31/test/string/strlen.c 2003-12-15 14:07:42.000000000 +0100
5073 +++ dietlibc/test/string/strlen.c 2008-02-19 01:28:13.000000000 +0100
5077 +#include <endian.h>
5079 +/* make it large enough to test all possible alignments, number of trailing
5080 + * bytes and word sizes */
5081 +#define BUFLEN (__WORDSIZE/8 * 4)
5084 - const char* x="foo bar baz";
5085 + /* will hold the string, the trailing zero and a test pattern */
5086 + char buf[BUFLEN + 1 + __WORDSIZE/8];
5089 assert(strlen("")==0);
5090 - assert(strlen(x)==11);
5091 - assert(strlen(x+5)==6);
5093 + for (len=0; len<BUFLEN; ++len) {
5094 + unsigned int mask;
5096 + buf[len] = len%10 + '0';
5097 + buf[len+1] = '\0';
5099 + for (mask=0; mask<(1u<<__WORDSIZE/8); ++mask) {
5103 + for (bit=0; bit<__WORDSIZE/8; ++bit)
5104 + buf[len+2+bit] = (mask & (1u<<bit)) ? 0xff : 0;
5106 + for (i=0; i<=len; ++i)
5107 + assert(strlen(buf+i)==len+1-i);
5113 diff -urN -x CVS dietlibc-0.31/test/string/strpbrk.c dietlibc/test/string/strpbrk.c
5114 --- dietlibc-0.31/test/string/strpbrk.c 1970-01-01 01:00:00.000000000 +0100
5115 +++ dietlibc/test/string/strpbrk.c 2008-02-19 01:28:13.000000000 +0100
5118 +#include <string.h>
5119 +#include <assert.h>
5123 + c="fnord:foo:bar:baz"; assert(strpbrk(c,":")==c+5);
5124 + c=":/::/:foo/bar:baz"; assert(strpbrk(c,"/:")==c);
5127 diff -urN -x CVS dietlibc-0.31/test/string/strspn.c dietlibc/test/string/strspn.c
5128 --- dietlibc-0.31/test/string/strspn.c 1970-01-01 01:00:00.000000000 +0100
5129 +++ dietlibc/test/string/strspn.c 2008-02-19 01:28:13.000000000 +0100
5132 +#include <string.h>
5133 +#include <assert.h>
5136 + assert(strspn("foo:bar:",":=b")==0);
5137 + assert(strspn("foo:bar:",":=of")==4);
5140 diff -urN -x CVS dietlibc-0.31/test/strlen.c dietlibc/test/strlen.c
5141 --- dietlibc-0.31/test/strlen.c 2003-02-20 16:57:13.000000000 +0100
5142 +++ dietlibc/test/strlen.c 1970-01-01 01:00:00.000000000 +0100
5144 -#include <assert.h>
5145 -#include <string.h>
5148 - const char* x="foo bar baz";
5149 - assert(strlen("")==0);
5150 - assert(strlen(x)==11);
5151 - assert(strlen(x+5)==6);
5154 diff -urN -x CVS dietlibc-0.31/test/wctomb.c dietlibc/test/wctomb.c
5155 --- dietlibc-0.31/test/wctomb.c 1970-01-01 01:00:00.000000000 +0100
5156 +++ dietlibc/test/wctomb.c 2007-09-09 03:38:16.000000000 +0200
5158 +#include <stdlib.h>
5161 +#include <locale.h>
5162 +#include <string.h>
5163 +#include <assert.h>
5176 + setlocale(LC_CTYPE,"de_DE.UTF8");
5178 + assert(wctomb(buf,c[0])==1);
5179 + assert(wctomb(buf+1,c[1])==1);
5180 + assert(wctomb(buf+2,c[2])==2);
5181 + assert(wctomb(buf+4,c[3])==1);
5182 + assert(wctomb(buf+5,c[4])==1);
5184 + assert(!strcmp(buf,"fn\xc3\x96rd"));
5187 diff -urN -x CVS dietlibc-0.31/test/wctype.c dietlibc/test/wctype.c
5188 --- dietlibc-0.31/test/wctype.c 1970-01-01 01:00:00.000000000 +0100
5189 +++ dietlibc/test/wctype.c 2007-09-09 04:11:18.000000000 +0200
5192 +#include <wctype.h>
5193 +#include <assert.h>
5197 + assert(x=wctype("lower"));
5198 + assert(iswctype(L'o',x));
5200 diff -urN -x CVS dietlibc-0.31/test/wmem.c dietlibc/test/wmem.c
5201 --- dietlibc-0.31/test/wmem.c 1970-01-01 01:00:00.000000000 +0100
5202 +++ dietlibc/test/wmem.c 2007-10-08 16:23:59.000000000 +0200
5205 +#include <assert.h>
5211 + /* does wmemset work? */
5212 + assert(wmemset(buf,0,100)==buf);
5213 + for (i=0; i<100; ++i) assert(buf[i]==0);
5215 + /* do wcscpy and wcscat work? */
5216 + assert(wcscpy(buf,L"fnord")==buf);
5217 + assert(wcscat(buf,L"blah")==buf);
5218 + assert(wcslen(buf)==9);
5219 + assert(wcscmp(buf,L"fnordblah")==0);
5221 + /* does wmemcmp work? */
5222 + assert(wmemcmp(buf,L"fnordxxx",5)==0);
5223 + assert(wmemcmp(buf,L"fnordxxx",6)<0);
5225 + /* check wmemcpy */
5226 + assert(wmemcpy(buf+5,buf,5)==buf+5);
5227 + assert(wmemcmp(buf,L"fnordfnord",10)==0);
5229 + /* does wmemmove handle overlapping properly */
5230 + assert(wmemmove(buf+1,buf,3)==buf+1);
5231 + assert(wmemcmp(buf,L"ffnod",5)==0);
5232 + assert(wmemmove(buf,buf+1,3)==buf);
5233 + assert(wmemcmp(buf,L"fnood",5)==0);
5235 + /* check wcsncpy */
5236 + assert(wcsncpy(buf,L"fnord",8)==buf);
5237 + assert(wmemcmp(buf,L"fnord\0\0\0",8)==0);
5239 + assert(wcsncpy(buf,L"test_",5)==buf);
5240 + assert(wmemcmp(buf,L"test_x\0\0",8)==0);
5242 + /* check wcsncat */
5243 + wmemset(buf,L'x',10);
5244 + wcscpy(buf,L"ab");
5245 + assert(wcsncat(buf,L"cd",5)==buf); // normal case
5246 + assert(wmemcmp(buf,L"abcd\0xxxxx",10)==0);
5247 + assert(wcsncat(buf,L"efgh",2)==buf); // truncation case
5248 + assert(wmemcmp(buf,L"abcdef\0xxx",10)==0);
5251 + wcscpy(buf,L"abracadabra");
5252 + assert(wcsstr(buf,L"abr")==buf);
5253 + assert(wcsstr(buf+1,L"abr")==buf+7);
5254 + assert(wcsstr(buf+8,L"abr")==0);
5256 diff -urN -x CVS dietlibc-0.31/TODO dietlibc/TODO
5257 --- dietlibc-0.31/TODO 2006-08-03 16:33:58.000000000 +0200
5258 +++ dietlibc/TODO 2008-05-09 06:36:56.000000000 +0200
5260 - look at mktime: "Falls tm_isdst == -1 gesetzt, so sollte mktime
5261 versuchen herauszufinden, ob Sommerzeit eingestellt ist (und laut linux
5262 manpage auch tzname setzen), ansonsten die angegebene DST
5266 - try to make zebra compile.
5269 set_thread_area -> set up TLD, for stack guard
5271 lsearch, lfind, hsearch, tsearch
5273 diff -urN -x CVS dietlibc-0.31/x86_64/dyn_syscalls.S dietlibc/x86_64/dyn_syscalls.S
5274 --- dietlibc-0.31/x86_64/dyn_syscalls.S 2006-10-13 22:14:30.000000000 +0200
5275 +++ dietlibc/x86_64/dyn_syscalls.S 2008-12-27 20:53:16.000000000 +0100
5277 #include "../syscalls.s/lgetxattr.S"
5278 #include "../syscalls.s/fgetxattr.S"
5280 +#include "../syscalls.s/timerfd.S"
5281 +#include "../syscalls.s/__signalfd.S"
5283 #define _exit __exit
5286 diff -urN -x CVS dietlibc-0.31/x86_64/strchr.S dietlibc/x86_64/strchr.S
5287 --- dietlibc-0.31/x86_64/strchr.S 1970-01-01 01:00:00.000000000 +0100
5288 +++ dietlibc/x86_64/strchr.S 2007-12-05 23:41:01.000000000 +0100
5291 +.type strchr,@function
5294 +.type index,@function
5310 diff -urN -x CVS dietlibc-0.31/x86_64/strcmp.S dietlibc/x86_64/strcmp.S
5311 --- dietlibc-0.31/x86_64/strcmp.S 1970-01-01 01:00:00.000000000 +0100
5312 +++ dietlibc/x86_64/strcmp.S 2007-12-05 23:41:01.000000000 +0100
5316 +.type strcmp,@function
5318 +.type strcoll,@function
5330 + /* end of string reached, return NULL */
5334 +/* In the C version we return (unsigned char)*b-(unsigned char)*a
5335 + but in assembler it is less trouble to return 1 or -1
5336 + depending on whether the carry flag is set.
5337 + The standard only wants positive, zero, or negative, so both are OK */
5341 diff -urN -x CVS dietlibc-0.31/x86_64/strcpy.S dietlibc/x86_64/strcpy.S
5342 --- dietlibc-0.31/x86_64/strcpy.S 1970-01-01 01:00:00.000000000 +0100
5343 +++ dietlibc/x86_64/strcpy.S 2008-09-05 17:13:29.000000000 +0200
5348 +.type strcpy,@function
5360 diff -urN -x CVS dietlibc-0.31/x86_64/syscalls.h dietlibc/x86_64/syscalls.h
5361 --- dietlibc-0.31/x86_64/syscalls.h 2006-09-19 00:08:39.000000000 +0200
5362 +++ dietlibc/x86_64/syscalls.h 2008-09-30 23:02:35.000000000 +0200
5363 @@ -325,6 +325,15 @@
5364 #define __NR_sync_file_range 277
5365 #define __NR_vmsplice 278
5366 #define __NR_move_pages 279
5367 +#define __NR_utimensat 280
5368 +#define __IGNORE_getcpu /* implemented as a vsyscall */
5369 +#define __NR_epoll_pwait 281
5370 +#define __NR_signalfd 282
5371 +#define __NR_timerfd 283
5372 +#define __NR_eventfd 284
5373 +#define __NR_fallocate 285
5374 +#define __NR_timerfd_settime 286
5375 +#define __NR_timerfd_gettime 287
5378 #define syscall_weak(name,wsym,sym) \
5379 @@ -356,14 +365,24 @@
5380 .type sym,@function; \
5383 +.ifge __NR_##name-256 ; \
5384 + mov $__NR_##name,%ax; \
5385 + jmp __unified_syscall_16bit; \
5387 mov $__NR_##name,%al; \
5388 - jmp __unified_syscall
5389 + jmp __unified_syscall; \
5392 #define syscall(name,sym) \
5394 .type sym,@function; \
5397 +.ifge __NR_##name-256 ; \
5398 + mov $__NR_##name,%ax; \
5399 + jmp __unified_syscall_16bit; \
5401 mov $__NR_##name,%al; \
5402 - jmp __unified_syscall
5403 + jmp __unified_syscall; \
5406 diff -urN -x CVS dietlibc-0.31/x86_64/time.S dietlibc/x86_64/time.S
5407 --- dietlibc-0.31/x86_64/time.S 1970-01-01 01:00:00.000000000 +0100
5408 +++ dietlibc/x86_64/time.S 2008-11-23 18:19:43.000000000 +0100
5410 +/* implement time(2) via gettimeofday(2) on x86-64 because gettimeofday
5411 + is a vsyscall (i.e. no actual switch to kernel mode) */
5414 +.type time,@function
5430 + .size time,.Lhere-time
5431 diff -urN -x CVS dietlibc-0.31/x86_64/unified.S dietlibc/x86_64/unified.S
5432 --- dietlibc-0.31/x86_64/unified.S 2005-05-08 01:07:33.000000000 +0200
5433 +++ dietlibc/x86_64/unified.S 2008-02-19 14:02:23.000000000 +0100
5435 #define SYS_exit 0x3c
5445 .global __unified_syscall
5446 +.global __unified_syscall_16bit
5450 +__unified_syscall_16bit: