1 diff -urN -x .git dietlibc-0.33/alpha/Makefile.add dietlibc/alpha/Makefile.add
2 --- dietlibc-0.33/alpha/Makefile.add 2012-01-24 18:24:24.000000000 +0000
3 +++ dietlibc/alpha/Makefile.add 2015-01-01 12:14:43.454938895 +0000
5 VPATH:=alpha:syscalls.s:$(VPATH)
7 LIBOBJ+=$(patsubst %,$(OBJDIR)/%,divq.o divl.o remq.o reml.o __time.o __alarm.o __CAS.o)
9 +$(OBJDIR)/__pause.o: include/signal.h
10 diff -urN -x .git dietlibc-0.33/alpha/start.S dietlibc/alpha/start.S
11 --- dietlibc-0.33/alpha/start.S 2006-05-29 16:30:53.000000000 +0000
12 +++ dietlibc/alpha/start.S 2015-01-01 12:14:43.454938895 +0000
18 +# warning "MAKE ME alpha ASSEMBLER!"
19 +1: ldq $19, $18 ; load *envp into $19
20 + addq $18, 1, $18 ; increment *envp
27 /* in v0 ($0) is the ld.so _fini pointer */
28 mov $0, $19 /* mov v0(dynload) to a3 */
29 diff -urN -x .git dietlibc-0.33/alpha/syscalls.h dietlibc/alpha/syscalls.h
30 --- dietlibc-0.33/alpha/syscalls.h 2008-05-06 17:18:34.000000000 +0000
31 +++ dietlibc/alpha/syscalls.h 2015-01-01 12:14:43.454938895 +0000
33 #define __NR_signalfd 476
34 #define __NR_timerfd 477
35 #define __NR_eventfd 478
37 +#define __NR_recvmmsg 479
38 +#define __NR_fallocate 480
39 +#define __NR_timerfd_create 481
40 +#define __NR_timerfd_settime 482
41 +#define __NR_timerfd_gettime 483
42 +#define __NR_signalfd4 484
43 +#define __NR_eventfd2 485
44 +#define __NR_epoll_create1 486
45 +#define __NR_dup3 487
46 +#define __NR_pipe2 488
47 +#define __NR_inotify_init1 489
48 +#define __NR_preadv 490
49 +#define __NR_pwritev 491
50 +#define __NR_rt_tgsigqueueinfo 492
51 +#define __NR_perf_event_open 493
52 +#define __NR_fanotify_init 494
53 +#define __NR_fanotify_mark 495
54 +#define __NR_prlimit64 496
55 +#define __NR_name_to_handle_at 497
56 +#define __NR_open_by_handle_at 498
57 +#define __NR_clock_adjtime 499
58 +#define __NR_syncfs 500
59 +#define __NR_setns 501
60 +#define __NR_accept4 502
61 +#define __NR_sendmmsg 503
62 +#define __NR_process_vm_readv 504
63 +#define __NR_process_vm_writev 505
64 +#define __NR_kcmp 506
65 +#define __NR_finit_module 507
66 +#define __NR_sched_setattr 508
67 +#define __NR_sched_getattr 509
68 +#define __NR_renameat2 510
70 #define syscall_weak(name,wsym,sym) \
72 diff -urN -x .git dietlibc-0.33/arm/__aeabi_read_tp.S dietlibc/arm/__aeabi_read_tp.S
73 --- dietlibc-0.33/arm/__aeabi_read_tp.S 1970-01-01 00:00:00.000000000 +0000
74 +++ dietlibc/arm/__aeabi_read_tp.S 2015-01-01 12:14:43.454938895 +0000
76 +#include "arm-features.h"
78 +FUNC_START __aeabi_read_tp
84 + mrc 15, 0, r0, cr13, cr0, 3
88 +FUNC_END __aeabi_read_tp
89 diff -urN -x .git dietlibc-0.33/arm/__aeabi_unwind_cpp.S dietlibc/arm/__aeabi_unwind_cpp.S
90 --- dietlibc-0.33/arm/__aeabi_unwind_cpp.S 2008-04-11 22:51:11.000000000 +0000
91 +++ dietlibc/arm/__aeabi_unwind_cpp.S 2015-01-01 12:14:43.454938895 +0000
94 -.global __aeabi_unwind_cpp_pr0
95 -.hidden __aeabi_unwind_cpp_pr0
96 -.type __aeabi_unwind_cpp_pr0, %function
97 +#include "arm-features.h"
99 -.global __aeabi_unwind_cpp_pr1
100 +FUNC_START __aeabi_unwind_cpp_pr0
101 +FUNC_START __aeabi_unwind_cpp_pr1
102 +FUNC_START __aeabi_unwind_cpp_pr2
103 +.hidden __aeabi_unwind_cpp_pr0
104 .hidden __aeabi_unwind_cpp_pr1
105 -.type __aeabi_unwind_cpp_pr1, %function
107 -.global __aeabi_unwind_cpp_pr2
108 .hidden __aeabi_unwind_cpp_pr2
109 -.type __aeabi_unwind_cpp_pr2, %function
111 -__aeabi_unwind_cpp_pr0:
112 -__aeabi_unwind_cpp_pr1:
113 -__aeabi_unwind_cpp_pr2:
114 - mov pc, lr @ return from subroutine
117 -.size __aeabi_unwind_cpp_pr0,.-__aeabi_unwind_cpp_pr0
118 -.size __aeabi_unwind_cpp_pr1,.-__aeabi_unwind_cpp_pr1
119 -.size __aeabi_unwind_cpp_pr2,.-__aeabi_unwind_cpp_pr2
120 +FUNC_END __aeabi_unwind_cpp_pr2
121 +FUNC_END __aeabi_unwind_cpp_pr1
122 +FUNC_END __aeabi_unwind_cpp_pr0
123 diff -urN -x .git dietlibc-0.33/arm/arm-features.h dietlibc/arm/arm-features.h
124 --- dietlibc-0.33/arm/arm-features.h 1970-01-01 00:00:00.000000000 +0000
125 +++ dietlibc/arm/arm-features.h 2015-01-01 12:14:43.454938895 +0000
129 +#ifndef H_DIETLIBC_ARM_FEATURES_H
130 +#define H_DIETLIBC_ARM_FEATURES_H
132 +/* Stolen from gcc (gcc/config/arm/lib1funcs.asm) */
133 +#if defined(__ARM_ARCH_2__)
134 +# define __ARM_ARCH__ 2
137 +#if defined(__ARM_ARCH_3__)
138 +# define __ARM_ARCH__ 3
141 +#if defined(__ARM_ARCH_3M__) || defined(__ARM_ARCH_4__) \
142 + || defined(__ARM_ARCH_4T__)
143 +# define __ARM_ARCH__ 4
146 +#if defined(__ARM_ARCH_5__) || defined(__ARM_ARCH_5T__) \
147 + || defined(__ARM_ARCH_5E__) || defined(__ARM_ARCH_5TE__) \
148 + || defined(__ARM_ARCH_5TEJ__)
149 +# define __ARM_ARCH__ 5
152 +#if defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) \
153 + || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6Z__) \
154 + || defined(__ARM_ARCH_6ZK__) || defined(__ARM_ARCH_6T2__) \
155 + || defined(__ARM_ARCH_6M__)
156 +# define __ARM_ARCH__ 6
159 +#if defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) \
160 + || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__)
161 +# define __ARM_ARCH__ 7
164 +#ifndef __ARM_ARCH__
165 +#error Unable to determine architecture.
168 +#define DIET_JMPBUFSZ_REGS_REGULAR 10*32/8 /* r4-r11, sp, pc */
169 +#define DIET_JMPBUFSZ_REGS_FPv4 16*64/8 /* d0-d15 */
171 +#if !defined(__SOFTFP__) || defined(__IWMMXT__)
172 +# define DIET_HAVE_COPROC_REGS 1
174 +# undef DIET_HAVE_COPROC_REGS
177 +#ifdef __ASSEMBLER__
179 +.macro FUNC_START name
183 + .type \name, %function
187 +.macro FUNC_START_WEAK name
191 + .type \name, %function
195 +.macro FUNC_END name
196 + .size \name, . - \name
200 +#if (__ARM_ARCH__ > 4) || defined(__ARM_ARCH_4T__)
207 +.macro SWI_UNIFIED name
209 + b __unified_syscall_swi
212 + b __unified_syscall
218 + b __unified_syscall_swi
221 + b __unified_syscall4
226 +#if defined(__ARM_ARCH_4__) || defined(__ARM_ARCH_4T__) || defined(__ARM_ARCH_5T__)
234 +#endif /* __ASSEMBLER__ */
236 +#endif /* H_DIETLIBC_ARM_FEATURES_H */
237 diff -urN -x .git dietlibc-0.33/arm/arm_set_tls.S dietlibc/arm/arm_set_tls.S
238 --- dietlibc-0.33/arm/arm_set_tls.S 1970-01-01 00:00:00.000000000 +0000
239 +++ dietlibc/arm/arm_set_tls.S 2015-01-01 12:14:43.454938895 +0000
241 +#include "syscalls.h"
242 +#include "arm-features.h"
246 +@ Calling convention:
247 +@ r0 ... thread data
249 +@ r0 ... low-level error code
250 +FUNC_START __arm_set_tls
252 + ldr r7, =__ARM_NR_set_tls
256 + @ we do not have much options here to handle errors because
257 + @ errno might not be available yet. Return error code as-is
258 + @ and let it handle by the caller
261 +FUNC_END __arm_set_tls
265 +#warning "setup-tls only implemented for ARM_EABI!"
268 diff -urN -x .git dietlibc-0.33/arm/clone.S dietlibc/arm/clone.S
269 --- dietlibc-0.33/arm/clone.S 2008-12-10 20:00:58.000000000 +0000
270 +++ dietlibc/arm/clone.S 2015-01-01 12:14:43.454938895 +0000
274 #include "syscalls.h"
275 +#include "arm-features.h"
282 @ Some slightly tricky stuff here... edit with care :-)
286 #define CLONE_VM 0x00000100
287 #define CLONE_THREAD 0x00010000
290 @ ; don't do this yet
296 +FUNC_START_WEAK clone
298 @ ; start with a sanity check
302 @ ; insert args into stack
307 @ ; do the system call
315 @ ; child sp is already in r1
326 - ldmfd sp!, {r4, r7}
327 + ldmfd sp!, {r4, r7}
328 blt __unified_syscall @ (return code < 0): handle as an error
335 tst ip, #CLONE_THREAD
340 str r0, [r1, #PID_OFFSET] @ ; not defined yet ??
341 str r0, [r1, #TID_OFFSET] @ ; not defined yet ??
345 @ ; pick the function arg and call address off the stack and execute
351 @ ; and we're done, passing return value through r0
352 b _exit @ branch to _exit (PIC safe)
362 +FUNC_START_WEAK clone
364 movs r12, r0 @ check function pointer
365 cmpne r1, #0 @ if function check for stack pointer
366 moveq r0, #-EINVAL @ if one is not available set errno value
368 ldmia sp!, { r0, pc } @ load function param and jump to thread function
370 1: b _exit @ branch to _exit (PIC safe)
375 diff -urN -x .git dietlibc-0.33/arm/dyn_syscalls.S dietlibc/arm/dyn_syscalls.S
376 --- dietlibc-0.33/arm/dyn_syscalls.S 2012-01-24 18:24:24.000000000 +0000
377 +++ dietlibc/arm/dyn_syscalls.S 2015-01-01 12:14:43.454938895 +0000
382 +#include "arm-features.h"
384 #include "../syscalls.s/environ.S"
385 #include "../syscalls.s/errno.S"
387 #include <dietfeatures.h>
388 #include "syscalls.h"
393 +# error "dyn_syscall.S not ported for EABI yet"
396 +FUNC_START __unified_syscall4
397 ldmfd sp!, {r4, r5, r6}
399 +FUNC_START __unified_syscall
406 #include "dietuglyweaks.h"
409 +FUNC_END __unified_syscall
410 +FUNC_END __unified_syscall4
412 /* ok now include all syscalls.s (*.S) and sysdep *.S */
415 #include "../syscalls.s/n_sigprocmask.S"
416 #include "../syscalls.s/n_sigsuspend.S"
417 #include "../syscalls.s/nanosleep.S"
418 -#include "../syscalls.s/nice.S"
419 #include "../syscalls.s/open.S"
420 #include "../syscalls.s/pause.S"
421 #include "../syscalls.s/personality.S"
423 #include "../syscalls.s/fgetxattr.S"
425 /* other asm-files w.o. changes ... */
435 diff -urN -x .git dietlibc-0.33/arm/__fadvise.c dietlibc/arm/__fadvise.c
436 --- dietlibc-0.33/arm/__fadvise.c 2011-03-03 18:40:05.000000000 +0000
437 +++ dietlibc/arm/__fadvise.c 2015-01-01 12:14:43.454938895 +0000
440 #include "syscalls.h"
441 +#define _LINUX_SOURCE
445 #ifndef __NR_fadvise64
446 long fadvise64_64(int fd, off64_t offset, off64_t len, int advice)
447 diff -urN -x .git dietlibc-0.33/arm/__guard.S dietlibc/arm/__guard.S
448 --- dietlibc-0.33/arm/__guard.S 2006-06-21 19:55:25.000000000 +0000
449 +++ dietlibc/arm/__guard.S 2015-01-01 12:14:43.454938895 +0000
453 .type __guard,#object
455 .type __stack_chk_guard,#object
460 +.size __guard, . - __guard
461 +.size __stack_chk_guard, . - __stack_chk_guard
462 diff -urN -x .git dietlibc-0.33/arm/__longjmp.S dietlibc/arm/__longjmp.S
463 --- dietlibc-0.33/arm/__longjmp.S 2001-07-02 16:06:48.000000000 +0000
464 +++ dietlibc/arm/__longjmp.S 2015-01-01 12:14:43.454938895 +0000
468 -.type __longjmp,function
470 +#include "arm-features.h"
472 +FUNC_START __longjmp
477 - lfm f4, 4, [ip], #48
479 +# if __ARM_ARCH__ == 7
481 +# ifdef __ARM_NEON__
482 + vldm ip!, {d16-d31}
488 - ldmia ip, {r4-r11, sp, pc}
491 +# warning "sigjmp will not restore iwmmxt coprocessor registers"
494 + ldmia ip!, {r4-r11, sp, pc}
496 diff -urN -x .git dietlibc-0.33/arm/Makefile.add dietlibc/arm/Makefile.add
497 --- dietlibc-0.33/arm/Makefile.add 2012-01-24 18:24:24.000000000 +0000
498 +++ dietlibc/arm/Makefile.add 2015-01-01 12:14:43.454938895 +0000
501 LIBOBJ+=$(OBJDIR)/md5asm.o $(OBJDIR)/__aeabi_unwind_cpp.o
502 LIBOBJ+=$(OBJDIR)/__fadvise.o $(OBJDIR)/arm_fadvise.o
503 +LIBOBJ+=$(OBJDIR)/__aeabi_read_tp.o $(OBJDIR)/arm_set_tls.o
504 CFLAGS+=-Os -fomit-frame-pointer -fstrict-aliasing
506 #CFLAGS+=-mabi=aapcs-linux -mno-thumb-interwork
507 diff -urN -x .git dietlibc-0.33/arm/mcount.S dietlibc/arm/mcount.S
508 --- dietlibc-0.33/arm/mcount.S 2002-05-09 03:50:17.000000000 +0000
509 +++ dietlibc/arm/mcount.S 2015-01-01 12:14:43.454938895 +0000
512 +#include "arm-features.h"
514 @ mcount.S: ARM assembler implementation of mcount
527 stmdb sp!, { r0 - r3, fp, ip, lr, pc } @ build stack frame
528 sub fp, ip, #4 @ setup new fp
530 bl __mcount @ call __mcount
532 ldmdb fp, { r0 - r3, fp, sp, pc } @ restore context from stack frame and return.
535 diff -urN -x .git dietlibc-0.33/arm/md5asm.S dietlibc/arm/md5asm.S
536 --- dietlibc-0.33/arm/md5asm.S 2008-12-10 20:00:58.000000000 +0000
537 +++ dietlibc/arm/md5asm.S 2015-01-01 12:14:43.454938895 +0000
539 -/*****************************************************************************
540 -* Copyright (C) 2002 Andre McCurdy <armccurdy@yahoo.co.uk>
542 -* "derived from the RSA Data Security, Inc. MD5 Message-Digest Algorithm"
544 -* This program is free software. you can redistribute it and/or modify
545 -* it under the terms of the GNU General Public License as published by
546 -* the Free Software Foundation; either version 2 of the License, or
547 -* (at your option) any later version.
549 -* This program is distributed in the hope that it will be useful,
550 -* but WITHOUT ANY WARRANTY, without even the implied warranty of
551 -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
552 -* GNU General Public License for more details.
554 -* You should have received a copy of the GNU General Public License
555 -* along with this program; if not, write to the Free Software
556 -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
558 -******************************************************************************
562 -* 2002/02/12: Andre McCurdy <armccurdy@yahoo.co.uk>
563 -* - Original created.
565 -* 2002/02/13: Andre McCurdy <armccurdy@yahoo.co.uk>
566 -* - Rewrote MD5Update in assembler (saves 52 bytes).
567 -* - Added guard so we don't compile anything for Big-Endian targets.
569 -* 2002/02/22: Andre McCurdy <armccurdy@yahoo.co.uk>
570 -* - Added new function MD5Update (a wrapper for the original version) which
571 -* checks for correct 32bit alignment of the input data pointer.
572 -* - Original MD5Update function renamed __MD5Update.
573 -* - __MD5Transform symbol no longer exported.
575 -* 2002/02/25: Andre McCurdy <armccurdy@yahoo.co.uk>
576 -* - MD5Update re-written in assembler (saves 12 bytes + lots of cycles :-)
578 -* 2002/03/07: Andre McCurdy <armccurdy@yahoo.co.uk>
579 -* - _Finally_ fixed hashing from an unaligned buffer in all cases :-)
581 -******************************************************************************
585 -* This code is believed to be Position Independent (ie can be safely used
586 -* as part of a shared library).
588 -*****************************************************************************/
592 -#if (__BYTE_ORDER == __LITTLE_ENDIAN)
605 - @ void MD5Init (MD5_CTX* context);
610 - adr r1, 1f @ r1 = base address of MD5InitData array
611 - ldmia r1, { r1 - r3, r12 } @ load 4 elements from MD5InitData array
612 - stmia r0, { r1 - r3, r12 } @ store into MD5 context->state[0..3]
614 - str r1, [r0, #0x10] @ initial count[0] = 0
615 - str r1, [r0, #0x14] @ initial count[1] = 0
616 - mov pc, lr @ return
618 -1: .word 0x67452301 @ initial MD5 context->state[0]
619 - .word 0xefcdab89 @ initial MD5 context->state[1]
620 - .word 0x98badcfe @ initial MD5 context->state[2]
621 - .word 0x10325476 @ initial MD5 context->state[3]
625 - @ void MD5Update (MD5_CTX* context, const uint8_t* buf, signed int len);
630 - stmdb sp!, { r4 - r8, lr }
631 - add r4, r0, #(6 * 4) @ r4 = &context->buffer[0]
632 - ldmdb r4, { r0, r3 } @ r0 = count[0], r3 = count[1]
633 - mov r5, r1 @ r5 = input
634 - mov r6, r0, lsr #3 @ r6 = (context->count[0] >> 3)
635 - and r6, r6, #0x3f @ r6 = byteIndex = ((context->count[0] >> 3) & 0x3f)
636 - adds r0, r0, r2, lsl #3
637 - adc r3, r3, r2, lsr #29
638 - stmdb r4, { r0, r3 } @ context->count += (inputBytes * 8)
639 - rsb r7, r6, #64 @ r7 = (64 - byteIndex) == partLen
640 - subs r8, r2, r7 @ r8 = (inputBytes - partLen)
644 - bl memcpy @ memcpy (&context->buffer[byteIndex], input, partLen);
645 - sub r0, r4, #(6 * 4)
648 - bl __MD5Transform @ __MD5Transform (context->state, context->buffer, 1);
649 - sub r0, r4, #(6 * 4)
651 - mov r2, r8, lsr #6 @ r2 = len = ((inputBytes - partLen) / 64)
652 - tst r1, #3 @ if (input & 0x03)
654 - beq __MD5Transform @ __MD5Transform (context->state, &input[partLen], len);
655 - bne __UnalignedMD5Transform @ else __UnalignedMD5Transform (context->state, &input[partLen], len);
661 -2: ldmia sp!, { r4 - r8, lr }
662 - b memcpy @ classic tail-call optimisation...
666 - @ static void __MD5Transform (uint32_t *buf, const uint32_t *in, int repeat);
671 -1: .word 0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee
672 - .word 0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501, ( 3f- 4f-4)
673 - .word 0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be, ( 3f- 4f-4)
674 - .word 0x6b901122, 0xfd987193, 0xa679438e, 0x49b40821, ( 3f- 4f-4)
675 - .word 0xf61e2562, 0xc040b340, 0x265e5a51, 0xe9b6c7aa, ( 4f- 4f-4)
676 - .word 0xd62f105d, 0x02441453, 0xd8a1e681, 0xe7d3fbc8, ( 5f- 9f-4)
677 - .word 0x21e1cde6, 0xc33707d6, 0xf4d50d87, 0x455a14ed, ( 6f- 9f-4)
678 - .word 0xa9e3e905, 0xfcefa3f8, 0x676f02d9, 0x8d2a4c8a, ( 7f- 9f-4)
679 - .word 0xfffa3942, 0x8771f681, 0x6d9d6122, 0xfde5380c, ( 9f- 9f-4)
680 - .word 0xa4beea44, 0x4bdecfa9, 0xf6bb4b60, 0xbebfbc70, (10f-14f-4)
681 - .word 0x289b7ec6, 0xeaa127fa, 0xd4ef3085, 0x04881d05, (11f-14f-4)
682 - .word 0xd9d4d039, 0xe6db99e5, 0x1fa27cf8, 0xc4ac5665, (12f-14f-4)
683 - .word 0xf4292244, 0x432aff97, 0xab9423a7, 0xfc93a039, (14f-14f-4)
684 - .word 0x655b59c3, 0x8f0ccc92, 0xffeff47d, 0x85845dd1, (15f-19f-4)
685 - .word 0x6fa87e4f, 0xfe2ce6e0, 0xa3014314, 0x4e0811a1, (16f-19f-4)
686 - .word 0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391, (17f-19f-4)
687 - .word 0x6e4120A9, 0x20657264, 0x7543634d, 0x00796472, (19f-19f-4)
692 - moveq pc, lr @ return if (repeat == 0)
693 - stmdb sp!, { r0, r2, r4 - r11, lr } @ stack 'buf', 'repeat' and all callee saved registers
694 - ldmia r0, { r2 - r5 } @ r2 = a, r3 = b, r4 = c, r5 = d
695 -2: adr r0, 1b @ r0 = base address of MD5MagicData
696 - ldmia r0!, { r6 - r9 } @ load first 4 elements from MD5MagicData
697 -3: ldmia r1!, { r10 - r12, lr } @ r10 = in[i], r11 = in[i+1], r12 = in[i+2], lr = in[i+3]
699 - add r10, r10, r6 @ r10 = in[i] + MD5MagicData[i]
700 - eor r6, r4, r5 @ r6 = (c ^ d)
701 - and r6, r6, r3 @ r6 = ((c ^ d) & b)
702 - eor r6, r6, r5 @ r6 = (((c ^ d) & b) ^ d)
703 - add r2, r2, r6 @ a = (((c ^ d) & b) ^ d) + a
704 - add r2, r2, r10 @ a = (((c ^ d) & b) ^ d) + a + (in[i] + MD5MagicData[i])
705 - add r2, r3, r2, ROR #(32 - 7) @ a = b + (a rotated left by 7 places)
707 - add r11, r11, r7 @ r11 = in[i+1] + MD5MagicData[i+1]
708 - eor r7, r3, r4 @ r7 = (b ^ c)
709 - and r7, r7, r2 @ r7 = ((b ^ c) & a)
710 - eor r7, r7, r4 @ r7 = (((b ^ c) & a) ^ c)
711 - add r5, r5, r7 @ d = (((b ^ c) & a) ^ c) + d
712 - add r5, r5, r11 @ d = (((b ^ c) & a) ^ c) + d + (in[i+1] + MD5MagicData[i+1])
713 - add r5, r2, r5, ROR #(32 - 12) @ d = a + (d rotated left by 12 places)
715 - add r12, r12, r8 @ r12 = in[i+2] + MD5MagicData[i+2]
716 - eor r8, r2, r3 @ r8 = (a ^ b)
717 - and r8, r8, r5 @ r8 = ((a ^ b) & d)
718 - eor r8, r8, r3 @ r8 = (((a ^ b) & d) ^ b)
719 - add r4, r4, r8 @ c = (((a ^ b) & d) ^ b) + c
720 - add r4, r4, r12 @ c = (((a ^ b) & d) ^ b) + c + (in[i+2] + MD5MagicData[i+2])
721 - add r4, r5, r4, ROR #(32 - 17) @ c = d + (c rotated left by 17 places)
723 - add lr, lr, r9 @ lr = in[i+3] + MD5MagicData[i+3]
724 - eor r9, r5, r2 @ r9 = (d ^ a)
725 - and r9, r9, r4 @ r9 = ((d ^ a) & c)
726 - eor r9, r9, r2 @ r9 = (((d ^ a) & c) ^ a)
727 - add r3, r3, r9 @ b = (((d ^ a) & c) ^ a) + b
728 - add r3, r3, lr @ b = (((d ^ a) & c) ^ a) + b + (in[i+3] + MD5MagicData[i+3])
729 - add r3, r4, r3, ROR #(32 - 22) @ b = c + (b rotated left by 22 places)
731 - ldmia r0!, { r6 - r10 } @ load next 4 elements from MD5MagicData
732 - add pc, pc, r10 @ and branch to next state
734 -4: ldr r10, [r1, #-(15*4)] @ r10 = in[ 1]
735 - ldr r11, [r1, #-(10*4)] @ r11 = in[ 6]
736 - ldr r12, [r1, #-( 5*4)] @ r12 = in[11]
737 - ldr lr, [r1, #-(16*4)] @ lr = in[ 0]
739 -5: ldr r10, [r1, #-(11*4)] @ r10 = in[ 5]
740 - ldr r11, [r1, #-( 6*4)] @ r11 = in[10]
741 - ldr r12, [r1, #-( 1*4)] @ r12 = in[15]
742 - ldr lr, [r1, #-(12*4)] @ lr = in[ 4]
744 -6: ldr r10, [r1, #-( 7*4)] @ r10 = in[ 9]
745 - ldr r11, [r1, #-( 2*4)] @ r11 = in[14]
746 - ldr r12, [r1, #-(13*4)] @ r12 = in[ 3]
747 - ldr lr, [r1, #-( 8*4)] @ lr = in[ 8]
749 -7: ldr r10, [r1, #-( 3*4)] @ r10 = in[13]
750 - ldr r11, [r1, #-(14*4)] @ r11 = in[ 2]
751 - ldr r12, [r1, #-( 9*4)] @ r12 = in[ 7]
752 - ldr lr, [r1, #-( 4*4)] @ lr = in[12]
754 -8: add r10, r10, r6 @ r10 = in[x] + MD5MagicData[i]
755 - eor r6, r3, r4 @ r6 = (b ^ c)
756 - and r6, r6, r5 @ r6 = ((b ^ c) & d)
757 - eor r6, r6, r4 @ r6 = (((b ^ c) & d) ^ c)
758 - add r2, r2, r6 @ a = (((b ^ c) & d) ^ c) + a
759 - add r2, r2, r10 @ a = (((b ^ c) & d) ^ c) + a + (in[x] + MD5MagicData[i])
760 - add r2, r3, r2, ROR #(32 - 5) @ a = b + (a rotated left by 5 places)
762 - add r11, r11, r7 @ r11 = in[x] + MD5MagicData[i+1]
763 - eor r7, r2, r3 @ r7 = (a ^ b)
764 - and r7, r7, r4 @ r7 = ((a ^ b) & c)
765 - eor r7, r7, r3 @ r7 = (((a ^ b) & c) ^ b)
766 - add r5, r5, r7 @ d = (((a ^ b) & c) ^ b) + d
767 - add r5, r5, r11 @ d = (((a ^ b) & c) ^ b) + d + (in[x] + MD5MagicData[i+1])
768 - add r5, r2, r5, ROR #(32 - 9) @ d = a + (d rotated left by 9 places)
770 - add r12, r12, r8 @ r12 = in[x] + MD5MagicData[i+2]
771 - eor r8, r5, r2 @ r8 = (d ^ a)
772 - and r8, r8, r3 @ r8 = ((d ^ a) & b)
773 - eor r8, r8, r2 @ r8 = (((d ^ a) & b) ^ a)
774 - add r4, r4, r8 @ c = (((d ^ a) & b) ^ a) + c
775 - add r4, r4, r12 @ c = (((d ^ a) & b) ^ a) + c + (in[x] + MD5MagicData[i+2])
776 - add r4, r5, r4, ROR #(32 - 14) @ c = d + (c rotated left by 14 places)
778 - add lr, lr, r9 @ lr = in[x] + MD5MagicData[i+3]
779 - eor r9, r4, r5 @ r9 = (c ^ d)
780 - and r9, r9, r2 @ r9 = ((c ^ d) & a)
781 - eor r9, r9, r5 @ r9 = (((c ^ d) & a) ^ d)
782 - add r3, r3, r9 @ b = (((c ^ d) & a) ^ d) + b
783 - add r3, r3, lr @ b = (((c ^ d) & a) ^ d) + b + (in[x] + MD5MagicData[i+3])
784 - add r3, r4, r3, ROR #(32 - 20) @ b = c + (b rotated left by 20 places)
786 - ldmia r0!, { r6 - r10 } @ load next 4 elements from MD5MagicData
787 - add pc, pc, r10 @ and branch to next state
789 -9: ldr r10, [r1, #-(11*4)] @ r10 = in[ 5]
790 - ldr r11, [r1, #-( 8*4)] @ r11 = in[ 8]
791 - ldr r12, [r1, #-( 5*4)] @ r12 = in[11]
792 - ldr lr, [r1, #-( 2*4)] @ lr = in[14]
794 -10: ldr r10, [r1, #-(15*4)] @ r10 = in[ 1]
795 - ldr r11, [r1, #-(12*4)] @ r11 = in[ 4]
796 - ldr r12, [r1, #-( 9*4)] @ r12 = in[ 7]
797 - ldr lr, [r1, #-( 6*4)] @ lr = in[10]
799 -11: ldr r10, [r1, #-( 3*4)] @ r10 = in[13]
800 - ldr r11, [r1, #-(16*4)] @ r11 = in[ 0]
801 - ldr r12, [r1, #-(13*4)] @ r12 = in[ 3]
802 - ldr lr, [r1, #-(10*4)] @ lr = in[ 6]
804 -12: ldr r10, [r1, #-( 7*4)] @ r10 = in[ 9]
805 - ldr r11, [r1, #-( 4*4)] @ r11 = in[12]
806 - ldr r12, [r1, #-( 1*4)] @ r12 = in[15]
807 - ldr lr, [r1, #-(14*4)] @ lr = in[ 2]
809 -13: add r10, r10, r6 @ r10 = in[x] + MD5MagicData[i]
810 - add r2, r2, r10 @ a += in[x] + MD5MagicData[i]
811 - eor r6, r3, r4 @ r6 = (b ^ c)
812 - eor r10, r6, r5 @ r10 = (b ^ c ^ d)
813 - add r2, r2, r10 @ a += (b ^ c ^ d)
814 - add r2, r3, r2, ROR #(32 - 4) @ a = b + (a rotated left by 4 places)
816 - add r11, r11, r7 @ r11 = in[x] + MD5MagicData[i+1]
817 - eor r7, r2, r6 @ r7 = (a ^ b ^ c)
818 - add r5, r5, r7 @ d = (a ^ b ^ c) + d
819 - add r5, r5, r11 @ d = (a ^ b ^ c) + d + (in[x] + MD5MagicData[i+1])
820 - add r5, r2, r5, ROR #(32 - 11) @ d = a + (d rotated left by 11 places)
822 - add r12, r12, r8 @ r12 = in[x] + MD5MagicData[i+2]
823 - add r4, r4, r12 @ c += in[x] + MD5MagicData[i+2]
824 - eor r8, r5, r2 @ r8 = (d ^ a)
825 - eor r12, r8, r3 @ r12 = (d ^ a ^ b)
826 - add r4, r4, r12 @ c += (d ^ a ^ b)
827 - add r4, r5, r4, ROR #(32 - 16) @ c = d + (c rotated left by 16 places)
829 - add lr, lr, r9 @ lr = in[x] + MD5MagicData[i+3]
830 - eor r9, r4, r8 @ r9 = (c ^ d ^ a)
831 - add r3, r3, r9 @ b = (c ^ d ^ a) + b
832 - add r3, r3, lr @ b = (c ^ d ^ a) + b + (in[x] + MD5MagicData[i+3])
833 - add r3, r4, r3, ROR #(32 - 23) @ b = c + (b rotated left by 23 places)
835 - ldmia r0!, { r6 - r10 } @ load next 4 elements from MD5MagicData
836 - add pc, pc, r10 @ and branch to next state
838 -14: ldr r10, [r1, #-(16*4)] @ r10 = in[ 0]
839 - ldr r11, [r1, #-( 9*4)] @ r11 = in[ 7]
840 - ldr r12, [r1, #-( 2*4)] @ r12 = in[14]
841 - ldr lr, [r1, #-(11*4)] @ lr = in[ 5]
843 -15: ldr r10, [r1, #-( 4*4)] @ r10 = in[12]
844 - ldr r11, [r1, #-(13*4)] @ r11 = in[ 3]
845 - ldr r12, [r1, #-( 6*4)] @ r12 = in[10]
846 - ldr lr, [r1, #-(15*4)] @ lr = in[ 1]
848 -16: ldr r10, [r1, #-( 8*4)] @ r10 = in[ 8]
849 - ldr r11, [r1, #-( 1*4)] @ r11 = in[15]
850 - ldr r12, [r1, #-(10*4)] @ r12 = in[ 6]
851 - ldr lr, [r1, #-( 3*4)] @ lr = in[13]
853 -17: ldr r10, [r1, #-(12*4)] @ r10 = in[ 4]
854 - ldr r11, [r1, #-( 5*4)] @ r11 = in[11]
855 - ldr r12, [r1, #-(14*4)] @ r12 = in[ 2]
856 - ldr lr, [r1, #-( 7*4)] @ lr = in[ 9]
858 -18: add r10, r10, r6 @ r10 = in[x] + MD5MagicData[i]
859 - add r2, r2, r10 @ a += in[x] + MD5MagicData[i]
860 - mvn r6, r5 @ r6 = ( ~d)
861 - orr r6, r6, r3 @ r6 = (b | ~d)
862 - eor r6, r6, r4 @ r6 = (c ^ (b | ~d))
863 - add r2, r2, r6 @ a += (c ^ (b | ~d))
864 - add r2, r3, r2, ROR #(32 - 6) @ a = b + (a rotated left by 6 places)
866 - add r11, r11, r7 @ r11 = in[x] + MD5MagicData[i]
867 - add r5, r5, r11 @ d += in[x] + MD5MagicData[i]
868 - mvn r7, r4 @ r7 = ( ~c)
869 - orr r7, r7, r2 @ r7 = (a | ~c)
870 - eor r7, r7, r3 @ r7 = (b ^ (a | ~c))
871 - add r5, r5, r7 @ d += (b ^ (a | ~c))
872 - add r5, r2, r5, ROR #(32 - 10) @ d = a + (d rotated left by 10 places)
874 - add r12, r12, r8 @ r12 = in[x] + MD5MagicData[i]
875 - add r4, r4, r12 @ c += in[x] + MD5MagicData[i]
876 - mvn r8, r3 @ r8 = ( ~b)
877 - orr r8, r8, r5 @ r8 = (d | ~b)
878 - eor r8, r8, r2 @ r8 = (a ^ (d | ~b))
879 - add r4, r4, r8 @ c += (a ^ (d | ~b))
880 - add r4, r5, r4, ROR #(32 - 15) @ c = d + (c rotated left by 15 places)
882 - add lr, lr, r9 @ lr = in[x] + MD5MagicData[i]
883 - add r3, r3, lr @ b += in[x] + MD5MagicData[i]
884 - mvn r9, r2 @ r9 = ( ~a)
885 - orr r9, r9, r4 @ r9 = (c | ~a)
886 - eor r9, r9, r5 @ r9 = (d ^ (c | ~a))
887 - add r3, r3, r9 @ b += (d ^ (c | ~a))
888 - add r3, r4, r3, ROR #(32 - 21) @ b = c + (b rotated left by 21 places)
890 - ldmia r0!, { r6 - r10 } @ load next 4 elements from MD5MagicData
891 - add pc, pc, r10 @ and branch to next state
893 -19: ldmia sp, { r0, r10 } @ fetch 'buf' and 'repeat' from the stack
894 - ldmia r0, { r6 - r9 } @ r6 = buf[0], r7 = buf[1], r8 = buf[2], r9 = buf[3] (original values..)
896 - strne r10, [sp, #4]
901 - stmia r0, { r2 - r5 }
903 - ldmia sp!, { r0, r2, r4 - r11, pc } @ restore all callee saved registers and return
907 - @ static void __UnalignedMD5Transform (uint32_t *buf, const uint8_t *in, int repeat);
910 -__UnalignedMD5Transform:
912 - stmdb sp!, { r4 - r7, lr }
913 - movs r4, r2, lsl #6 @ r4 = (repeat * 64)
914 - ldmeqia sp!, { r4 - r7, pc } @ if ((repeat * 64) == 0) return;
915 - mov r5, r0 @ r5 = state
916 - mov r6, r1 @ r6 = in
917 - sub sp, sp, #256 @ create 256 byte temp buffer
921 - movcs r7, #256 @ r7 = (blockCount * 64) = min((repeat * 64), (4 * 64))
924 - bl memcpy @ memcpy (blockBuffer, in, (blockCount * 64));
928 - bl __MD5Transform @ __MD5Transform (state, blockBuffer, blockCount);
929 - subs r4, r4, #256 @ (repeat * 64) -= (4 * 64);
930 - add r6, r6, #256 @ in += (4 * 64);
931 - bgt 1b @ loop while (repeat > 0)
932 - add sp, sp, #256 @ return temp buffer to stack
933 - ldmia sp!, { r4 - r7, pc } @ return
936 -#endif /* __BYTE_ORDER == __LITTLE_ENDIAN */
939 +#include "arm-features.h"
941 +/*****************************************************************************
942 +* Copyright (C) 2002 Andre McCurdy <armccurdy@yahoo.co.uk>
944 +* "derived from the RSA Data Security, Inc. MD5 Message-Digest Algorithm"
946 +* This program is free software. you can redistribute it and/or modify
947 +* it under the terms of the GNU General Public License as published by
948 +* the Free Software Foundation; either version 2 of the License, or
949 +* (at your option) any later version.
951 +* This program is distributed in the hope that it will be useful,
952 +* but WITHOUT ANY WARRANTY, without even the implied warranty of
953 +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
954 +* GNU General Public License for more details.
956 +* You should have received a copy of the GNU General Public License
957 +* along with this program; if not, write to the Free Software
958 +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
960 +******************************************************************************
964 +* 2002/02/12: Andre McCurdy <armccurdy@yahoo.co.uk>
965 +* - Original created.
967 +* 2002/02/13: Andre McCurdy <armccurdy@yahoo.co.uk>
968 +* - Rewrote MD5Update in assembler (saves 52 bytes).
969 +* - Added guard so we don't compile anything for Big-Endian targets.
971 +* 2002/02/22: Andre McCurdy <armccurdy@yahoo.co.uk>
972 +* - Added new function MD5Update (a wrapper for the original version) which
973 +* checks for correct 32bit alignment of the input data pointer.
974 +* - Original MD5Update function renamed __MD5Update.
975 +* - __MD5Transform symbol no longer exported.
977 +* 2002/02/25: Andre McCurdy <armccurdy@yahoo.co.uk>
978 +* - MD5Update re-written in assembler (saves 12 bytes + lots of cycles :-)
980 +* 2002/03/07: Andre McCurdy <armccurdy@yahoo.co.uk>
981 +* - _Finally_ fixed hashing from an unaligned buffer in all cases :-)
983 +******************************************************************************
987 +* This code is believed to be Position Independent (ie can be safely used
988 +* as part of a shared library).
990 +*****************************************************************************/
993 +#include "arm-features.h"
995 +#if (__BYTE_ORDER == __LITTLE_ENDIAN)
998 + @ void MD5Init (MD5_CTX* context);
1002 + adr r1, 1f @ r1 = base address of MD5InitData array
1003 + ldmia r1, { r1 - r3, r12 } @ load 4 elements from MD5InitData array
1004 + stmia r0, { r1 - r3, r12 } @ store into MD5 context->state[0..3]
1006 + str r1, [r0, #0x10] @ initial count[0] = 0
1007 + str r1, [r0, #0x14] @ initial count[1] = 0
1011 +1: .word 0x67452301 @ initial MD5 context->state[0]
1012 + .word 0xefcdab89 @ initial MD5 context->state[1]
1013 + .word 0x98badcfe @ initial MD5 context->state[2]
1014 + .word 0x10325476 @ initial MD5 context->state[3]
1018 + @ void MD5Update (MD5_CTX* context, const uint8_t* buf, signed int len);
1021 +FUNC_START MD5Update
1022 + stmdb sp!, { r4 - r8, lr }
1023 + add r4, r0, #(6 * 4) @ r4 = &context->buffer[0]
1024 + ldmdb r4, { r0, r3 } @ r0 = count[0], r3 = count[1]
1025 + mov r5, r1 @ r5 = input
1026 + mov r6, r0, lsr #3 @ r6 = (context->count[0] >> 3)
1027 + and r6, r6, #0x3f @ r6 = byteIndex = ((context->count[0] >> 3) & 0x3f)
1028 + adds r0, r0, r2, lsl #3
1029 + adc r3, r3, r2, lsr #29
1030 + stmdb r4, { r0, r3 } @ context->count += (inputBytes * 8)
1031 + rsb r7, r6, #64 @ r7 = (64 - byteIndex) == partLen
1032 + subs r8, r2, r7 @ r8 = (inputBytes - partLen)
1036 + bl memcpy @ memcpy (&context->buffer[byteIndex], input, partLen);
1037 + sub r0, r4, #(6 * 4)
1040 + bl __MD5Transform @ __MD5Transform (context->state, context->buffer, 1);
1041 + sub r0, r4, #(6 * 4)
1043 + mov r2, r8, lsr #6 @ r2 = len = ((inputBytes - partLen) / 64)
1044 + tst r1, #3 @ if (input & 0x03)
1046 + beq __MD5Transform @ __MD5Transform (context->state, &input[partLen], len);
1047 + bne __UnalignedMD5Transform @ else __UnalignedMD5Transform (context->state, &input[partLen], len);
1053 +2: ldmia sp!, { r4 - r8, lr }
1054 + b memcpy @ classic tail-call optimisation...
1058 + @ static void __MD5Transform (uint32_t *buf, const uint32_t *in, int repeat);
1064 +1: .word 0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee
1065 + .word 0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501, ( 3f- 4f-4)
1066 + .word 0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be, ( 3f- 4f-4)
1067 + .word 0x6b901122, 0xfd987193, 0xa679438e, 0x49b40821, ( 3f- 4f-4)
1068 + .word 0xf61e2562, 0xc040b340, 0x265e5a51, 0xe9b6c7aa, ( 4f- 4f-4)
1069 + .word 0xd62f105d, 0x02441453, 0xd8a1e681, 0xe7d3fbc8, ( 5f- 9f-4)
1070 + .word 0x21e1cde6, 0xc33707d6, 0xf4d50d87, 0x455a14ed, ( 6f- 9f-4)
1071 + .word 0xa9e3e905, 0xfcefa3f8, 0x676f02d9, 0x8d2a4c8a, ( 7f- 9f-4)
1072 + .word 0xfffa3942, 0x8771f681, 0x6d9d6122, 0xfde5380c, ( 9f- 9f-4)
1073 + .word 0xa4beea44, 0x4bdecfa9, 0xf6bb4b60, 0xbebfbc70, (10f-14f-4)
1074 + .word 0x289b7ec6, 0xeaa127fa, 0xd4ef3085, 0x04881d05, (11f-14f-4)
1075 + .word 0xd9d4d039, 0xe6db99e5, 0x1fa27cf8, 0xc4ac5665, (12f-14f-4)
1076 + .word 0xf4292244, 0x432aff97, 0xab9423a7, 0xfc93a039, (14f-14f-4)
1077 + .word 0x655b59c3, 0x8f0ccc92, 0xffeff47d, 0x85845dd1, (15f-19f-4)
1078 + .word 0x6fa87e4f, 0xfe2ce6e0, 0xa3014314, 0x4e0811a1, (16f-19f-4)
1079 + .word 0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391, (17f-19f-4)
1080 + .word 0x6e4120A9, 0x20657264, 0x7543634d, 0x00796472, (19f-19f-4)
1086 + moveq pc, lr @ return if (repeat == 0)
1087 + stmdb sp!, { r0, r2, r4 - r11, lr } @ stack 'buf', 'repeat' and all callee saved registers
1088 + ldmia r0, { r2 - r5 } @ r2 = a, r3 = b, r4 = c, r5 = d
1089 +2: adr r0, 1b @ r0 = base address of MD5MagicData
1090 + ldmia r0!, { r6 - r9 } @ load first 4 elements from MD5MagicData
1091 +3: ldmia r1!, { r10 - r12, lr } @ r10 = in[i], r11 = in[i+1], r12 = in[i+2], lr = in[i+3]
1093 + add r10, r10, r6 @ r10 = in[i] + MD5MagicData[i]
1094 + eor r6, r4, r5 @ r6 = (c ^ d)
1095 + and r6, r6, r3 @ r6 = ((c ^ d) & b)
1096 + eor r6, r6, r5 @ r6 = (((c ^ d) & b) ^ d)
1097 + add r2, r2, r6 @ a = (((c ^ d) & b) ^ d) + a
1098 + add r2, r2, r10 @ a = (((c ^ d) & b) ^ d) + a + (in[i] + MD5MagicData[i])
1099 + add r2, r3, r2, ROR #(32 - 7) @ a = b + (a rotated left by 7 places)
1101 + add r11, r11, r7 @ r11 = in[i+1] + MD5MagicData[i+1]
1102 + eor r7, r3, r4 @ r7 = (b ^ c)
1103 + and r7, r7, r2 @ r7 = ((b ^ c) & a)
1104 + eor r7, r7, r4 @ r7 = (((b ^ c) & a) ^ c)
1105 + add r5, r5, r7 @ d = (((b ^ c) & a) ^ c) + d
1106 + add r5, r5, r11 @ d = (((b ^ c) & a) ^ c) + d + (in[i+1] + MD5MagicData[i+1])
1107 + add r5, r2, r5, ROR #(32 - 12) @ d = a + (d rotated left by 12 places)
1109 + add r12, r12, r8 @ r12 = in[i+2] + MD5MagicData[i+2]
1110 + eor r8, r2, r3 @ r8 = (a ^ b)
1111 + and r8, r8, r5 @ r8 = ((a ^ b) & d)
1112 + eor r8, r8, r3 @ r8 = (((a ^ b) & d) ^ b)
1113 + add r4, r4, r8 @ c = (((a ^ b) & d) ^ b) + c
1114 + add r4, r4, r12 @ c = (((a ^ b) & d) ^ b) + c + (in[i+2] + MD5MagicData[i+2])
1115 + add r4, r5, r4, ROR #(32 - 17) @ c = d + (c rotated left by 17 places)
1117 + add lr, lr, r9 @ lr = in[i+3] + MD5MagicData[i+3]
1118 + eor r9, r5, r2 @ r9 = (d ^ a)
1119 + and r9, r9, r4 @ r9 = ((d ^ a) & c)
1120 + eor r9, r9, r2 @ r9 = (((d ^ a) & c) ^ a)
1121 + add r3, r3, r9 @ b = (((d ^ a) & c) ^ a) + b
1122 + add r3, r3, lr @ b = (((d ^ a) & c) ^ a) + b + (in[i+3] + MD5MagicData[i+3])
1123 + add r3, r4, r3, ROR #(32 - 22) @ b = c + (b rotated left by 22 places)
1125 + ldmia r0!, { r6 - r10 } @ load next 4 elements from MD5MagicData
1126 + add pc, pc, r10 @ and branch to next state
1128 +4: ldr r10, [r1, #-(15*4)] @ r10 = in[ 1]
1129 + ldr r11, [r1, #-(10*4)] @ r11 = in[ 6]
1130 + ldr r12, [r1, #-( 5*4)] @ r12 = in[11]
1131 + ldr lr, [r1, #-(16*4)] @ lr = in[ 0]
1133 +5: ldr r10, [r1, #-(11*4)] @ r10 = in[ 5]
1134 + ldr r11, [r1, #-( 6*4)] @ r11 = in[10]
1135 + ldr r12, [r1, #-( 1*4)] @ r12 = in[15]
1136 + ldr lr, [r1, #-(12*4)] @ lr = in[ 4]
1138 +6: ldr r10, [r1, #-( 7*4)] @ r10 = in[ 9]
1139 + ldr r11, [r1, #-( 2*4)] @ r11 = in[14]
1140 + ldr r12, [r1, #-(13*4)] @ r12 = in[ 3]
1141 + ldr lr, [r1, #-( 8*4)] @ lr = in[ 8]
1143 +7: ldr r10, [r1, #-( 3*4)] @ r10 = in[13]
1144 + ldr r11, [r1, #-(14*4)] @ r11 = in[ 2]
1145 + ldr r12, [r1, #-( 9*4)] @ r12 = in[ 7]
1146 + ldr lr, [r1, #-( 4*4)] @ lr = in[12]
1148 +8: add r10, r10, r6 @ r10 = in[x] + MD5MagicData[i]
1149 + eor r6, r3, r4 @ r6 = (b ^ c)
1150 + and r6, r6, r5 @ r6 = ((b ^ c) & d)
1151 + eor r6, r6, r4 @ r6 = (((b ^ c) & d) ^ c)
1152 + add r2, r2, r6 @ a = (((b ^ c) & d) ^ c) + a
1153 + add r2, r2, r10 @ a = (((b ^ c) & d) ^ c) + a + (in[x] + MD5MagicData[i])
1154 + add r2, r3, r2, ROR #(32 - 5) @ a = b + (a rotated left by 5 places)
1156 + add r11, r11, r7 @ r11 = in[x] + MD5MagicData[i+1]
1157 + eor r7, r2, r3 @ r7 = (a ^ b)
1158 + and r7, r7, r4 @ r7 = ((a ^ b) & c)
1159 + eor r7, r7, r3 @ r7 = (((a ^ b) & c) ^ b)
1160 + add r5, r5, r7 @ d = (((a ^ b) & c) ^ b) + d
1161 + add r5, r5, r11 @ d = (((a ^ b) & c) ^ b) + d + (in[x] + MD5MagicData[i+1])
1162 + add r5, r2, r5, ROR #(32 - 9) @ d = a + (d rotated left by 9 places)
1164 + add r12, r12, r8 @ r12 = in[x] + MD5MagicData[i+2]
1165 + eor r8, r5, r2 @ r8 = (d ^ a)
1166 + and r8, r8, r3 @ r8 = ((d ^ a) & b)
1167 + eor r8, r8, r2 @ r8 = (((d ^ a) & b) ^ a)
1168 + add r4, r4, r8 @ c = (((d ^ a) & b) ^ a) + c
1169 + add r4, r4, r12 @ c = (((d ^ a) & b) ^ a) + c + (in[x] + MD5MagicData[i+2])
1170 + add r4, r5, r4, ROR #(32 - 14) @ c = d + (c rotated left by 14 places)
1172 + add lr, lr, r9 @ lr = in[x] + MD5MagicData[i+3]
1173 + eor r9, r4, r5 @ r9 = (c ^ d)
1174 + and r9, r9, r2 @ r9 = ((c ^ d) & a)
1175 + eor r9, r9, r5 @ r9 = (((c ^ d) & a) ^ d)
1176 + add r3, r3, r9 @ b = (((c ^ d) & a) ^ d) + b
1177 + add r3, r3, lr @ b = (((c ^ d) & a) ^ d) + b + (in[x] + MD5MagicData[i+3])
1178 + add r3, r4, r3, ROR #(32 - 20) @ b = c + (b rotated left by 20 places)
1180 + ldmia r0!, { r6 - r10 } @ load next 4 elements from MD5MagicData
1181 + add pc, pc, r10 @ and branch to next state
1183 +9: ldr r10, [r1, #-(11*4)] @ r10 = in[ 5]
1184 + ldr r11, [r1, #-( 8*4)] @ r11 = in[ 8]
1185 + ldr r12, [r1, #-( 5*4)] @ r12 = in[11]
1186 + ldr lr, [r1, #-( 2*4)] @ lr = in[14]
1188 +10: ldr r10, [r1, #-(15*4)] @ r10 = in[ 1]
1189 + ldr r11, [r1, #-(12*4)] @ r11 = in[ 4]
1190 + ldr r12, [r1, #-( 9*4)] @ r12 = in[ 7]
1191 + ldr lr, [r1, #-( 6*4)] @ lr = in[10]
1193 +11: ldr r10, [r1, #-( 3*4)] @ r10 = in[13]
1194 + ldr r11, [r1, #-(16*4)] @ r11 = in[ 0]
1195 + ldr r12, [r1, #-(13*4)] @ r12 = in[ 3]
1196 + ldr lr, [r1, #-(10*4)] @ lr = in[ 6]
1198 +12: ldr r10, [r1, #-( 7*4)] @ r10 = in[ 9]
1199 + ldr r11, [r1, #-( 4*4)] @ r11 = in[12]
1200 + ldr r12, [r1, #-( 1*4)] @ r12 = in[15]
1201 + ldr lr, [r1, #-(14*4)] @ lr = in[ 2]
1203 +13: add r10, r10, r6 @ r10 = in[x] + MD5MagicData[i]
1204 + add r2, r2, r10 @ a += in[x] + MD5MagicData[i]
1205 + eor r6, r3, r4 @ r6 = (b ^ c)
1206 + eor r10, r6, r5 @ r10 = (b ^ c ^ d)
1207 + add r2, r2, r10 @ a += (b ^ c ^ d)
1208 + add r2, r3, r2, ROR #(32 - 4) @ a = b + (a rotated left by 4 places)
1210 + add r11, r11, r7 @ r11 = in[x] + MD5MagicData[i+1]
1211 + eor r7, r2, r6 @ r7 = (a ^ b ^ c)
1212 + add r5, r5, r7 @ d = (a ^ b ^ c) + d
1213 + add r5, r5, r11 @ d = (a ^ b ^ c) + d + (in[x] + MD5MagicData[i+1])
1214 + add r5, r2, r5, ROR #(32 - 11) @ d = a + (d rotated left by 11 places)
1216 + add r12, r12, r8 @ r12 = in[x] + MD5MagicData[i+2]
1217 + add r4, r4, r12 @ c += in[x] + MD5MagicData[i+2]
1218 + eor r8, r5, r2 @ r8 = (d ^ a)
1219 + eor r12, r8, r3 @ r12 = (d ^ a ^ b)
1220 + add r4, r4, r12 @ c += (d ^ a ^ b)
1221 + add r4, r5, r4, ROR #(32 - 16) @ c = d + (c rotated left by 16 places)
1223 + add lr, lr, r9 @ lr = in[x] + MD5MagicData[i+3]
1224 + eor r9, r4, r8 @ r9 = (c ^ d ^ a)
1225 + add r3, r3, r9 @ b = (c ^ d ^ a) + b
1226 + add r3, r3, lr @ b = (c ^ d ^ a) + b + (in[x] + MD5MagicData[i+3])
1227 + add r3, r4, r3, ROR #(32 - 23) @ b = c + (b rotated left by 23 places)
1229 + ldmia r0!, { r6 - r10 } @ load next 4 elements from MD5MagicData
1230 + add pc, pc, r10 @ and branch to next state
1232 +14: ldr r10, [r1, #-(16*4)] @ r10 = in[ 0]
1233 + ldr r11, [r1, #-( 9*4)] @ r11 = in[ 7]
1234 + ldr r12, [r1, #-( 2*4)] @ r12 = in[14]
1235 + ldr lr, [r1, #-(11*4)] @ lr = in[ 5]
1237 +15: ldr r10, [r1, #-( 4*4)] @ r10 = in[12]
1238 + ldr r11, [r1, #-(13*4)] @ r11 = in[ 3]
1239 + ldr r12, [r1, #-( 6*4)] @ r12 = in[10]
1240 + ldr lr, [r1, #-(15*4)] @ lr = in[ 1]
1242 +16: ldr r10, [r1, #-( 8*4)] @ r10 = in[ 8]
1243 + ldr r11, [r1, #-( 1*4)] @ r11 = in[15]
1244 + ldr r12, [r1, #-(10*4)] @ r12 = in[ 6]
1245 + ldr lr, [r1, #-( 3*4)] @ lr = in[13]
1247 +17: ldr r10, [r1, #-(12*4)] @ r10 = in[ 4]
1248 + ldr r11, [r1, #-( 5*4)] @ r11 = in[11]
1249 + ldr r12, [r1, #-(14*4)] @ r12 = in[ 2]
1250 + ldr lr, [r1, #-( 7*4)] @ lr = in[ 9]
1252 +18: add r10, r10, r6 @ r10 = in[x] + MD5MagicData[i]
1253 + add r2, r2, r10 @ a += in[x] + MD5MagicData[i]
1254 + mvn r6, r5 @ r6 = ( ~d)
1255 + orr r6, r6, r3 @ r6 = (b | ~d)
1256 + eor r6, r6, r4 @ r6 = (c ^ (b | ~d))
1257 + add r2, r2, r6 @ a += (c ^ (b | ~d))
1258 + add r2, r3, r2, ROR #(32 - 6) @ a = b + (a rotated left by 6 places)
1260 + add r11, r11, r7 @ r11 = in[x] + MD5MagicData[i]
1261 + add r5, r5, r11 @ d += in[x] + MD5MagicData[i]
1262 + mvn r7, r4 @ r7 = ( ~c)
1263 + orr r7, r7, r2 @ r7 = (a | ~c)
1264 + eor r7, r7, r3 @ r7 = (b ^ (a | ~c))
1265 + add r5, r5, r7 @ d += (b ^ (a | ~c))
1266 + add r5, r2, r5, ROR #(32 - 10) @ d = a + (d rotated left by 10 places)
1268 + add r12, r12, r8 @ r12 = in[x] + MD5MagicData[i]
1269 + add r4, r4, r12 @ c += in[x] + MD5MagicData[i]
1270 + mvn r8, r3 @ r8 = ( ~b)
1271 + orr r8, r8, r5 @ r8 = (d | ~b)
1272 + eor r8, r8, r2 @ r8 = (a ^ (d | ~b))
1273 + add r4, r4, r8 @ c += (a ^ (d | ~b))
1274 + add r4, r5, r4, ROR #(32 - 15) @ c = d + (c rotated left by 15 places)
1276 + add lr, lr, r9 @ lr = in[x] + MD5MagicData[i]
1277 + add r3, r3, lr @ b += in[x] + MD5MagicData[i]
1278 + mvn r9, r2 @ r9 = ( ~a)
1279 + orr r9, r9, r4 @ r9 = (c | ~a)
1280 + eor r9, r9, r5 @ r9 = (d ^ (c | ~a))
1281 + add r3, r3, r9 @ b += (d ^ (c | ~a))
1282 + add r3, r4, r3, ROR #(32 - 21) @ b = c + (b rotated left by 21 places)
1284 + ldmia r0!, { r6 - r10 } @ load next 4 elements from MD5MagicData
1285 + add pc, pc, r10 @ and branch to next state
1287 +19: ldmia sp, { r0, r10 } @ fetch 'buf' and 'repeat' from the stack
1288 + ldmia r0, { r6 - r9 } @ r6 = buf[0], r7 = buf[1], r8 = buf[2], r9 = buf[3] (original values..)
1290 + strne r10, [sp, #4]
1295 + stmia r0, { r2 - r5 }
1297 + ldmia sp!, { r0, r2, r4 - r11, pc } @ restore all callee saved registers and return
1301 + @ static void __UnalignedMD5Transform (uint32_t *buf, const uint8_t *in, int repeat);
1304 +__UnalignedMD5Transform:
1306 + stmdb sp!, { r4 - r7, lr }
1307 + movs r4, r2, lsl #6 @ r4 = (repeat * 64)
1308 + ldmeqia sp!, { r4 - r7, pc } @ if ((repeat * 64) == 0) return;
1309 + mov r5, r0 @ r5 = state
1310 + mov r6, r1 @ r6 = in
1311 + sub sp, sp, #256 @ create 256 byte temp buffer
1315 + movcs r7, #256 @ r7 = (blockCount * 64) = min((repeat * 64), (4 * 64))
1318 + bl memcpy @ memcpy (blockBuffer, in, (blockCount * 64));
1321 + mov r2, r7, lsr #6
1322 + bl __MD5Transform @ __MD5Transform (state, blockBuffer, blockCount);
1323 + subs r4, r4, #256 @ (repeat * 64) -= (4 * 64);
1324 + add r6, r6, #256 @ in += (4 * 64);
1325 + bgt 1b @ loop while (repeat > 0)
1326 + add sp, sp, #256 @ return temp buffer to stack
1327 + ldmia sp!, { r4 - r7, pc } @ return
1330 +#endif /* __BYTE_ORDER == __LITTLE_ENDIAN */
1333 diff -urN -x .git dietlibc-0.33/arm/mmap.S dietlibc/arm/mmap.S
1334 --- dietlibc-0.33/arm/mmap.S 2008-12-10 20:00:58.000000000 +0000
1335 +++ dietlibc/arm/mmap.S 2015-01-01 12:14:43.454938895 +0000
1337 +#include "arm-features.h"
1340 #include "syscalls.h"
1346 - mov pc, lr @ return
1351 diff -urN -x .git dietlibc-0.33/arm/setjmp.S dietlibc/arm/setjmp.S
1352 --- dietlibc-0.33/arm/setjmp.S 2008-12-10 20:00:58.000000000 +0000
1353 +++ dietlibc/arm/setjmp.S 2015-01-01 12:14:43.454938895 +0000
1360 +#include "arm-features.h"
1362 +FUNC_START_WEAK setjmp
1363 +FUNC_START __setjmp
1365 -.global __sigsetjmp
1370 - sfm f4, 4, [r0], #48
1374 +FUNC_START_WEAK sigsetjmp
1375 +FUNC_START __sigsetjmp
1377 +#ifdef DIET_HAVE_COPROC_REGS
1378 + /* we have to work on a copy of 'r0' (jmpbuf *) */
1383 +# if __ARM_ARCH__ >= 7
1384 + vstmia ip!, {d0-d15}
1385 +# ifdef __ARM_NEON__
1386 + vstmia ip!, {d16-d31}
1394 +# warning "setjmp will not save iwmmxt coprocessor registers"
1397 +#ifndef DIET_HAVE_COPROC_REGS
1398 stmia r0, {r4-r11, sp, lr}
1403 + stmia ip!, {r4-r11, sp, lr}
1407 +FUNC_END __sigsetjmp
1409 diff -urN -x .git dietlibc-0.33/arm/start.S dietlibc/arm/start.S
1410 --- dietlibc-0.33/arm/start.S 2012-01-24 18:24:24.000000000 +0000
1411 +++ dietlibc/arm/start.S 2015-01-01 12:14:43.454938895 +0000
1414 #include "dietfeatures.h"
1415 #include "syscalls.h"
1418 -#ifdef __ARM_EABI__
1428 +#include "arm-features.h"
1435 mov fp, #0 @ clear the frame pointer
1437 add a2, sp, #4 @ argv
1439 add a3, a2, a1, lsl #2 @ &argv[argc]
1440 add a3, a3, #4 @ envp
1441 str a3, [ip, #0] @ environ = envp
1445 +#ifdef WANT_ELFINFO
1446 + mov r6, a3 @ work on a copy of a3 so that common
1447 + @ 'main(argc, argv, envp)' function
1449 +1: ldr r5, [r6], #4 @ load *envp and increment it
1450 + cmp r5, #0 @ read value==0?
1452 + str r6, [ip, #4] @ __elfinfo = envp
1455 + bl CALL_IN_STARTCODE
1458 @ The exit status from main() is already in r0.
1459 @ We need to branch to 'exit' in case we have linked with 'atexit'.
1468 +FUNC_START_WEAK exit
1470 swi 0 @ never returns.
1487 mov a4, a1 @ save dynamic ld.so _fini
1492 - str a3, [sl, ip] @ environ = envp
1493 + str a3, [ip, sl]! @ environ = envp; ip = GOT(environ)
1495 str a3, [ip, #0] @ environ = envp
1498 +#ifdef WANT_ELFINFO
1499 + mov r6, a3 @ work on a copy of a3 so that common
1500 + @ 'main(argc, argv, envp)' function
1502 +1: ldr r5, [r6], #4 @ load *envp and increment it
1503 + cmp r5, #0 @ read value==0?
1506 + str r6, [ip, sl] @ __elfinfo = envp
1508 + str r6, [ip, #4] @ __elfinfo = envp
1513 stmdb sp!, { r0 - r3 }
1516 @ We need to branch to 'exit' in case we have linked with 'atexit'.
1525 +FUNC_START_WEAK exit
1527 mov r4, r0 @ save a copy of exit status
1531 swi $__NR_exit @ never returns.
1538 .L3: .word environ(GOT)
1539 .L4: .word _GLOBAL_OFFSET_TABLE_-(1b+8)
1540 diff -urN -x .git dietlibc-0.33/arm/strcpy.S dietlibc/arm/strcpy.S
1541 --- dietlibc-0.33/arm/strcpy.S 2005-08-05 00:29:18.000000000 +0000
1542 +++ dietlibc/arm/strcpy.S 2015-01-01 12:14:43.454938895 +0000
1544 #include "dietfeatures.h"
1545 +#include "arm-features.h"
1553 #ifndef WANT_SMALL_STRING_ROUTINES
1562 - .size strcpy,.Lfe1-strcpy
1565 diff -urN -x .git dietlibc-0.33/arm/strlen.S dietlibc/arm/strlen.S
1566 --- dietlibc-0.33/arm/strlen.S 2005-08-05 00:29:18.000000000 +0000
1567 +++ dietlibc/arm/strlen.S 2015-01-01 12:14:43.454938895 +0000
1569 #include "dietfeatures.h"
1570 +#include "arm-features.h"
1581 teq a1, #0 @ is string pointer NULL ??
1582 moveq pc, lr @ if so, return 0
1590 #ifndef WANT_SMALL_STRING_ROUTINES
1596 - .size strlen,.Lstrlen-strlen
1598 diff -urN -x .git dietlibc-0.33/arm/syscalls.h dietlibc/arm/syscalls.h
1599 --- dietlibc-0.33/arm/syscalls.h 2012-01-24 18:24:24.000000000 +0000
1600 +++ dietlibc/arm/syscalls.h 2015-01-01 12:14:43.454938895 +0000
1601 @@ -365,6 +365,38 @@
1602 #define __NR_fallocate (__NR_SYSCALL_BASE+352)
1603 #define __NR_timerfd_settime (__NR_SYSCALL_BASE+353)
1604 #define __NR_timerfd_gettime (__NR_SYSCALL_BASE+354)
1605 +#define __NR_signalfd4 (__NR_SYSCALL_BASE+355)
1606 +#define __NR_eventfd2 (__NR_SYSCALL_BASE+356)
1607 +#define __NR_epoll_create1 (__NR_SYSCALL_BASE+357)
1608 +#define __NR_dup3 (__NR_SYSCALL_BASE+358)
1609 +#define __NR_pipe2 (__NR_SYSCALL_BASE+359)
1610 +#define __NR_inotify_init1 (__NR_SYSCALL_BASE+360)
1611 +#define __NR_preadv (__NR_SYSCALL_BASE+361)
1612 +#define __NR_pwritev (__NR_SYSCALL_BASE+362)
1613 +#define __NR_rt_tgsigqueueinfo (__NR_SYSCALL_BASE+363)
1614 +#define __NR_perf_event_open (__NR_SYSCALL_BASE+364)
1615 +#define __NR_recvmmsg (__NR_SYSCALL_BASE+365)
1616 +#define __NR_accept4 (__NR_SYSCALL_BASE+366)
1617 +#define __NR_fanotify_init (__NR_SYSCALL_BASE+367)
1618 +#define __NR_fanotify_mark (__NR_SYSCALL_BASE+368)
1619 +#define __NR_prlimit64 (__NR_SYSCALL_BASE+369)
1620 +#define __NR_name_to_handle_at (__NR_SYSCALL_BASE+370)
1621 +#define __NR_open_by_handle_at (__NR_SYSCALL_BASE+371)
1622 +#define __NR_clock_adjtime (__NR_SYSCALL_BASE+372)
1623 +#define __NR_syncfs (__NR_SYSCALL_BASE+373)
1624 +#define __NR_sendmmsg (__NR_SYSCALL_BASE+374)
1625 +#define __NR_setns (__NR_SYSCALL_BASE+375)
1626 +#define __NR_process_vm_readv (__NR_SYSCALL_BASE+376)
1627 +#define __NR_process_vm_writev (__NR_SYSCALL_BASE+377)
1628 +#define __NR_kcmp (__NR_SYSCALL_BASE+378)
1629 +#define __NR_finit_module (__NR_SYSCALL_BASE+379)
1630 +#define __NR_sched_setattr (__NR_SYSCALL_BASE+380)
1631 +#define __NR_sched_getattr (__NR_SYSCALL_BASE+381)
1632 +#define __NR_renameat2 (__NR_SYSCALL_BASE+382)
1633 +#define __NR_seccomp (__NR_SYSCALL_BASE+383)
1634 +#define __NR_getrandom (__NR_SYSCALL_BASE+384)
1635 +#define __NR_memfd_create (__NR_SYSCALL_BASE+385)
1639 * The following SWIs are ARM private.
1641 #define __ARGS_getpeername 0
1642 #define __ARGS_socketpair 0
1643 #define __ARGS_send 0
1644 -#define __ARGS_sendto 0
1645 +#define __ARGS_sendto 6
1646 #define __ARGS_recv 0
1647 -#define __ARGS_recvfrom 0
1648 +#define __ARGS_recvfrom 6
1649 #define __ARGS_shutdown 0
1650 #define __ARGS_setsockopt 0
1651 #define __ARGS_getsockopt 0
1652 @@ -768,73 +800,59 @@
1653 #define __ARGS_timerfd_settime 0
1654 #define __ARGS_timerfd_gettime 0
1656 +#define __ARGS_signalfd4 0
1657 +#define __ARGS_eventfd2 0
1658 +#define __ARGS_epoll_create1 0
1659 +#define __ARGS_dup3 0
1660 +#define __ARGS_pipe2 0
1661 +#define __ARGS_inotify_init1 0
1662 +#define __ARGS_preadv 0
1663 +#define __ARGS_pwritev 0
1664 +#define __ARGS_rt_tgsigqueueinfo 0
1665 +#define __ARGS_perf_event_open 1
1666 +#define __ARGS_recvmmsg 1
1667 +#define __ARGS_accept4 0
1668 +#define __ARGS_fanotify_init 0
1669 +#define __ARGS_fanotify_mark 1
1670 +#define __ARGS_prlimit64 0
1671 +#define __ARGS_name_to_handle_at 1
1672 +#define __ARGS_open_by_handle_at 0
1673 +#define __ARGS_clock_adjtime 0
1674 +#define __ARGS_syncfs 0
1675 +#define __ARGS_sendmmsg 0
1676 +#define __ARGS_setns 0
1677 +#define __ARGS_process_vm_readv 1
1678 +#define __ARGS_process_vm_writev 1
1679 +#define __ARGS_kcmp 1
1680 +#define __ARGS_finit_module 0
1683 #ifdef __ASSEMBLER__
1685 -#ifdef __ARM_EABI__
1686 +#include "arm-features.h"
1688 #define syscall_weak(name,wsym,sym) __syscall_weak __NR_##name, wsym, sym, __ARGS_##name
1689 .macro __syscall_weak name wsym sym typ
1691 -.type \wsym,function
1694 -.type \sym,function
1697 - stmfd sp!,{r4,r5,r7,lr}
1702 - b __unified_syscall
1703 +FUNC_START_WEAK \wsym
1704 +__syscall \name, \sym, \typ
1708 +#ifdef __ARM_EABI__
1710 #define syscall(name,sym) __syscall __NR_##name, sym, __ARGS_##name
1711 .macro __syscall name sym typ
1713 -.type \sym,function
1716 - stmfd sp!,{r4,r5,r7,lr}
1721 - b __unified_syscall
1724 + b __unified_syscall_swi
1730 -#define syscall_weak(name,wsym,sym) __syscall_weak $__NR_##name, wsym, sym, __ARGS_##name
1731 -.macro __syscall_weak name wsym sym typ
1733 -.type \wsym,function
1736 -.type \sym,function
1741 - stmfd sp!,{r4, r5, r6}
1742 - ldmia ip, {r4, r5, r6}
1746 - b __unified_syscall4
1748 - b __unified_syscall
1752 #define syscall(name,sym) __syscall $__NR_##name, sym, __ARGS_##name
1753 .macro __syscall name sym typ
1755 -.type \sym,function
1761 stmfd sp!,{r4, r5, r6}
1770 diff -urN -x .git dietlibc-0.33/arm/__testandset.S dietlibc/arm/__testandset.S
1771 --- dietlibc-0.33/arm/__testandset.S 2001-03-09 19:30:52.000000000 +0000
1772 +++ dietlibc/arm/__testandset.S 2015-01-01 12:14:43.454938895 +0000
1775 -.global __testandset
1777 +#include "arm-features.h"
1779 +FUNC_START __testandset
1782 +# if __ARM_ARCH__ < 6
1787 + strex r3, r1, [r2]
1792 +FUNC_END __testandset
1793 diff -urN -x .git dietlibc-0.33/arm/unified.S dietlibc/arm/unified.S
1794 --- dietlibc-0.33/arm/unified.S 2012-01-24 18:24:24.000000000 +0000
1795 +++ dietlibc/arm/unified.S 2015-01-01 12:14:43.454938895 +0000
1798 #include <dietfeatures.h>
1801 -#ifdef __ARM_EABI__
1806 - .global __unified_syscall
1807 - .global __unified_syscall4
1809 +#include "arm-features.h"
1813 -__unified_syscall4:
1817 + * r0-r3 ... syscall arguments 0-3
1818 + * ip ... syscall number
1820 +FUNC_START __unified_syscall_swi
1821 + .hidden __unified_syscall_swi
1822 + stmfd sp!,{r4,r5,r7,lr}
1826 + /* fallthrough to __unified4_syscall */
1827 +FUNC_END __unified_syscall_swi
1830 + * r0 ... syscall return value
1831 + * original r4-r7 + lr on stack
1833 +FUNC_START __unified_syscall
1834 + .hidden __unified_syscall
1836 +#ifndef WANT_THREAD_SAFE
1848 + bl __errno_location
1852 + ldmfd sp!,{r4,r5,r7,pc}
1854 +FUNC_END __unified_syscall
1856 /* here we go and "reuse" the return for weak-void functions */
1857 #include "dietuglyweaks.h"
1859 - mov pc, lr @ return
1864 -__unified_syscall4:
1867 +FUNC_START __unified_syscall4
1868 ldmia sp!, {r4, r5, r6}
1871 +FUNC_START __unified_syscall
1873 movcc pc, lr @ return value comes direct from kernel.
1876 /* here we go and "reuse" the return for weak-void functions */
1877 #include "dietuglyweaks.h"
1879 - mov pc, lr @ return
1882 #ifndef WANT_THREAD_SAFE
1886 +FUNC_END __unified_syscall
1887 +FUNC_END __unified_syscall4
1890 diff -urN -x .git dietlibc-0.33/arm/waitpid.S dietlibc/arm/waitpid.S
1891 --- dietlibc-0.33/arm/waitpid.S 2008-12-10 20:00:58.000000000 +0000
1892 +++ dietlibc/arm/waitpid.S 2015-01-01 12:14:43.454938895 +0000
1895 -#ifdef __ARM_EABI__
1901 -.type waitpid, %function
1903 -.global __libc_waitpid
1904 -.type __libc_waitpid, %function
1908 - .size waitpid, .-waitpid
1909 +#include "arm-features.h"
1911 +FUNC_START_WEAK waitpid
1912 +FUNC_START __libc_waitpid
1915 +FUNC_END __libc_waitpid
1917 diff -urN -x .git dietlibc-0.33/CHANGES dietlibc/CHANGES
1918 --- dietlibc-0.33/CHANGES 2012-11-02 11:17:28.000000000 +0000
1919 +++ dietlibc/CHANGES 2015-01-01 12:14:43.451605563 +0000
1922 + move stpcpy from libcompat to lib as it is now part of POSIX (Enrico Scholz)
1923 + add linux/seccomp.h linux/prctl.h linux/audit.h linux/elf-em.h linux/filter.h
1924 + SECURITY: make sure all assembler files mark the stack non-executable so
1925 + the kernel can map the stack of the whole program as non-executable
1926 + support compiling with clang (no cross compiling yet, and the resulting
1927 + binary code is significantly larger than with gcc)
1928 + implement experimental C11 threads
1929 + fix fgets (Andreas Förster)
1930 + add eventfd, inotify_init1, epoll_init1, accept4, recvmmsg, sendmmsg
1931 + add dup3, fanotify_init, fanotify_mark, signalfd4, timerfd_settime
1932 + add timerfd_gettime, setns, memfd_create, getrandom, syncfs
1933 + add preadv, pwritev
1934 + add getcontext, setcontext, makecontext, swapcontext (i386 and x86_64 only for now)
1935 + add implementation of hsearch and friends
1938 first stab at getting TLS to work in actual threads
1939 use fs: to find current thread on x86_64
1940 diff -urN -x .git dietlibc-0.33/contrib/dnsd.c dietlibc/contrib/dnsd.c
1941 --- dietlibc-0.33/contrib/dnsd.c 2010-09-25 17:03:25.000000000 +0000
1942 +++ dietlibc/contrib/dnsd.c 2015-01-01 12:14:43.458272230 +0000
1943 @@ -281,55 +281,54 @@
1946 static void init_sockets(int* sock6,int* sock4,int port,char* v6ip,char* v4ip) {
1950 *sock6=-1; *sock4=-1;
1951 - s6=socket(PF_INET6,SOCK_DGRAM,IPPROTO_UDP);
1952 - s4=socket(PF_INET,SOCK_DGRAM,IPPROTO_UDP);
1953 - if (s4==-1 && s6==-1) {
1954 + _s6=socket(PF_INET6,SOCK_DGRAM,IPPROTO_UDP);
1955 + _s4=socket(PF_INET,SOCK_DGRAM,IPPROTO_UDP);
1956 + if (_s4==-1 && _s6==-1) {
1961 - setsockopt(s6,SOL_SOCKET,SO_REUSEADDR,&one,sizeof(one));
1963 + setsockopt(_s6,SOL_SOCKET,SO_REUSEADDR,&one,sizeof(one));
1964 memset(&sa6,0,sizeof(sa6));
1965 sa6.sin6_family=PF_INET6;
1966 sa6.sin6_port=htons(port);
1967 - if (bind(s6,(struct sockaddr*)&sa6,sizeof(struct sockaddr_in6))==-1) {
1968 + if (bind(_s6,(struct sockaddr*)&sa6,sizeof(struct sockaddr_in6))==-1) {
1969 perror("bind IPv6");
1977 - setsockopt(s4,SOL_SOCKET,SO_REUSEADDR,&one,sizeof(one));
1979 + setsockopt(_s4,SOL_SOCKET,SO_REUSEADDR,&one,sizeof(one));
1980 memset(&sa4,0,sizeof(sa4));
1981 sa4.sin_family=PF_INET;
1982 sa4.sin_port=htons(port);
1983 - if (bind(s4,(struct sockaddr*)&sa4,sizeof(struct sockaddr_in))==-1) {
1984 - if (errno!=EADDRINUSE || s6==-1)
1985 + if (bind(_s4,(struct sockaddr*)&sa4,sizeof(struct sockaddr_in))==-1) {
1986 + if (errno!=EADDRINUSE || _s6==-1)
1987 perror("bind IPv4");
1994 - if (s4==-1 && s6==-1) return;
1995 + if (_s4==-1 && _s6==-1) return;
2002 struct ipv6_mreq opt;
2003 - setsockopt(s6,IPPROTO_IPV6,IPV6_UNICAST_HOPS,&val,sizeof(val));
2004 - setsockopt(s6,IPPROTO_IPV6,IPV6_MULTICAST_LOOP,&one,sizeof(one));
2005 + setsockopt(_s6,IPPROTO_IPV6,IPV6_UNICAST_HOPS,&val,sizeof(val));
2006 + setsockopt(_s6,IPPROTO_IPV6,IPV6_MULTICAST_LOOP,&one,sizeof(one));
2007 memcpy(&opt.ipv6mr_multiaddr,v6ip,16);
2008 opt.ipv6mr_interface=0;
2009 - setsockopt(s6,IPPROTO_IPV6,IPV6_ADD_MEMBERSHIP,&opt,sizeof opt);
2010 - setsockopt(s6,IPPROTO_IPV6,IPV6_PKTINFO,&one,sizeof one);
2011 + setsockopt(_s6,IPPROTO_IPV6,IPV6_ADD_MEMBERSHIP,&opt,sizeof opt);
2012 + setsockopt(_s6,IPPROTO_IPV6,IPV6_PKTINFO,&one,sizeof one);
2016 - int s=(s4==-1?s6:s4);
2017 + int s=(_s4==-1?_s6:_s4);
2018 setsockopt(s,SOL_IP,IP_TTL,&val,sizeof(val));
2019 memcpy(&opt.imr_multiaddr.s_addr,v4ip,4);
2020 opt.imr_interface.s_addr=0;
2032 diff -urN -x .git dietlibc-0.33/.cvsignore dietlibc/.cvsignore
2033 --- dietlibc-0.33/.cvsignore 2007-03-09 13:42:12.000000000 +0000
2034 +++ dietlibc/.cvsignore 2015-01-01 12:14:43.451605563 +0000
2039 +include/errno_definition.h
2041 diff -urN -x .git dietlibc-0.33/diet.c dietlibc/diet.c
2042 --- dietlibc-0.33/diet.c 2012-11-02 11:17:28.000000000 +0000
2043 +++ dietlibc/diet.c 2015-01-01 12:14:43.461605562 +0000
2047 static const char* Os[] = {
2048 - "i386","-Os","-mpreferred-stack-boundary=2",
2049 + "i386","-Os","-mpreferred-stack-boundary=4",
2050 "-falign-functions=1","-falign-jumps=1",
2051 "-falign-loops=1","-fomit-frame-pointer",0,
2054 "sparc","-Os","-mcpu=supersparc",0,
2055 "sparc64","-Os","-m64","-mhard-quad-float",0,
2056 "alpha","-Os","-fomit-frame-pointer",0,
2058 "s390x","-Os","-fomit-frame-pointer",0,
2059 "sh","-Os","-fomit-frame-pointer",0,
2060 "ia64","-Os","-fno-omit-frame-pointer",0,
2061 - "x86_64","-Os","-fstrict-aliasing","-momit-leaf-frame-pointer","-mfancy-math-387",0,
2064 static void usage(void) {
2071 for (i=1; i<argc; ++i) {
2072 if (!strcmp(argv[i],"-m32")) m=32; else
2073 @@ -144,6 +143,10 @@
2074 memmove(shortplatform,argv[1],(size_t)(tmp2-cc));
2075 platform[tmp2-cc+len]=0;
2076 if (shortplatform[0]=='i' && shortplatform[2]=='8' && shortplatform[3]=='6') shortplatform[1]='3';
2077 + else if (strcmp(shortplatform, "powerpc") == 0)
2078 + strcpy(shortplatform, "ppc");
2079 + else if (strcmp(shortplatform, "powerpc64") == 0)
2080 + strcpy(shortplatform, "ppc64");
2084 @@ -193,15 +196,14 @@
2085 shortplatform="ia64";
2088 - char *tmp=platform+strlen(platform);
2089 - strcpy(tmp,shortplatform);
2090 - shortplatform=tmp;
2091 + char *tmp4=platform+strlen(platform);
2092 + strcpy(tmp4,shortplatform);
2093 + shortplatform=tmp4;
2096 /* MIPS needs special handling. If argv contains -EL, change
2097 * platform name to mipsel */
2098 if (!strcmp(shortplatform,"mips")) {
2100 for (i=1; i<argc; ++i)
2101 if (!strcmp(argv[i],"-EL"))
2102 strcpy(shortplatform,"mipsel");
2106 if (argv[i][0]=='-' && (argv[i][1]=='O' || argv[i][1]=='f' ||
2107 - (argv[i][1]=='m' && argv[i][2]!='3' && argv[i][2]!='6'))) {
2108 + (argv[i][1]=='m' && argv[i][2]!='3' && argv[i][2]!='6' && argv[i][2]!='x'))) {
2109 if (strcmp(argv[i],"-fpic") && strcmp(argv[i],"-fno-pic"))
2116 - char* tmp=getenv("HOME");
2117 + tmp=getenv("HOME");
2119 if (strlen(tmp)+strlen(cc)<900) {
2120 strcpy(manglebuf,tmp);
2122 if ((fd=open(manglebuf,O_RDONLY))>=0) {
2123 int len=read(fd,manglebuf,1023);
2128 for (i=1; i<len; ++i) {
2134 for (i=0; newargv[i]; i++) {
2135 __write2(newargv[i]);
2137 diff -urN -x .git dietlibc-0.33/dietdirent.h dietlibc/dietdirent.h
2138 --- dietlibc-0.33/dietdirent.h 2002-07-03 20:33:37.000000000 +0000
2139 +++ dietlibc/dietdirent.h 2015-01-01 12:14:43.461605562 +0000
2141 #include <sys/shm.h>
2143 +#include "dietpagesize.h"
2145 struct __dirstream {
2147 - char buf[PAGE_SIZE-(sizeof (int)*3)];
2150 + unsigned char is_64;
2151 + char buf[] __attribute__((__aligned__(8)));
2152 }; /* stream data from opendir() */
2154 +struct linux_dirent {
2155 + unsigned long d_ino;
2156 + unsigned long d_off;
2157 + unsigned short d_reclen;
2161 +struct linux_dirent64 {
2164 + unsigned short d_reclen;
2165 + unsigned char d_type;
2169 +#define __DIRSTREAM_BUF_SIZE (__DIET_PAGE_SIZE - offsetof(struct __dirstream, buf))
2170 diff -urN -x .git dietlibc-0.33/dietelfinfo.h dietlibc/dietelfinfo.h
2171 --- dietlibc-0.33/dietelfinfo.h 1970-01-01 00:00:00.000000000 +0000
2172 +++ dietlibc/dietelfinfo.h 2015-01-01 12:14:43.461605562 +0000
2174 +#include "dietfeatures.h"
2176 +#ifdef WANT_ELFINFO
2178 +#include <endian.h>
2179 +#include <stdint.h>
2181 +/* TODO: exported interface from <linux/elf.h> has been changed in 2.6.25 so
2182 + * the 'elf_addr_t' type is not available anymore. Hence, derive it from
2183 + * __WORDSIZE__. */
2185 +#if __WORDSIZE == 64
2186 +typedef uint64_t __diet_elf_addr_t;
2187 +#elif __WORDSIZE == 32
2188 +typedef uint32_t __diet_elf_addr_t;
2191 +__diet_elf_addr_t const * __get_elf_aux_value(unsigned int tag)
2192 + __attribute__((__visibility__("hidden"),__const__)) __pure;
2194 diff -urN -x .git dietlibc-0.33/dietfeatures.h dietlibc/dietfeatures.h
2195 --- dietlibc-0.33/dietfeatures.h 2012-11-02 11:17:28.000000000 +0000
2196 +++ dietlibc/dietfeatures.h 2015-01-01 12:14:43.461605562 +0000
2200 /* make the startcode, etc. dynamic aware ({con,de}structors) */
2201 -/* #define WANT_DYNAMIC */
2202 +// #define WANT_DYNAMIC
2204 /* GDB support in the dynamic linker */
2205 #define WANT_LD_SO_GDB_SUPPORT
2206 @@ -142,6 +142,16 @@
2210 +/* Some platforms like x86_64, ppc* or mips do not have a fixed PAGE_SIZE.
2211 + * Select WANT_DYN_PAGESIZE to detect the current PAGE_SIZE at runtime. Else,
2212 + * define WANT_STATIC_PAGESIZE to a proper value (must be a power of 2)
2213 + * matching the configured pagesize of the kernel where your binaries are
2216 + * Selecting WANT_DYN_PAGESIZE enlarges the startup code by around 1-3
2217 + * instructions and might add an additional __elfinfo symbol */
2218 +#define WANT_DYN_PAGESIZE
2219 +/* #define WANT_STATIC_PAGESIZE 0x10000UL */
2222 /* stop uncommenting here ;-) */
2223 @@ -161,13 +171,6 @@
2224 #define WANT_SMALL_STRING_ROUTINES
2227 -#ifdef WANT_THREAD_SAFE
2228 -#ifndef __ASSEMBLER__
2229 -#define errno (*__errno_location())
2235 /* with shared libraries you MUST have a dynamic aware startcode */
2236 #ifndef WANT_DYNAMIC
2237 @@ -179,4 +182,12 @@
2241 +#if defined(__x86_64__) && defined(__ILP32__)
2242 +#undef WANT_LARGEFILE_BACKCOMPAT
2245 +#ifdef WANT_DYN_PAGESIZE
2246 +#define WANT_ELFINFO
2250 diff -urN -x .git dietlibc-0.33/dietpagesize.h dietlibc/dietpagesize.h
2251 --- dietlibc-0.33/dietpagesize.h 1970-01-01 00:00:00.000000000 +0000
2252 +++ dietlibc/dietpagesize.h 2015-01-01 12:14:43.461605562 +0000
2254 +#ifndef H_DIETLIBC_DIETPAGESIZE_H
2255 +#define H_DIETLIBC_DIETPAGESIZE_H
2257 +#include <strings.h>
2258 +#include "dietfeatures.h"
2260 +extern size_t __libc_getpagesize(void) __attribute__((__const__)) __pure;
2262 +#if defined(WANT_STATIC_PAGESIZE)
2263 +# define __DIET_PAGE_SIZE_PREDEF (WANT_STATIC_PAGESIZE)
2264 +# define __DIET_PAGE_SHIFT_PREDEF (ffs(__DIET_PAGE_SIZE_PREDEF)-1)
2265 +#elif defined(__alpha__) || defined(__sparc__)
2266 +# define __DIET_PAGE_SIZE_PREDEF (8192UL)
2267 +# define __DIET_PAGE_SHIFT_PREDEF (13)
2268 +#elif defined(__powerpc64__)
2269 +# define __DIET_PAGE_SIZE_PREDEF (65536UL)
2270 +# define __DIET_PAGE_SHIFT_PREDEF (16)
2272 +# define __DIET_PAGE_SIZE_PREDEF (4096UL)
2273 +# define __DIET_PAGE_SHIFT_PREDEF (12)
2276 +#ifdef WANT_DYN_PAGESIZE
2277 +# define __DIET_PAGE_SIZE (__libc_getpagesize())
2278 +# define __DIET_PAGE_SHIFT (ffs(__DIET_PAGE_SIZE)-1)
2280 +# define __DIET_PAGE_SIZE __DIET_PAGE_SIZE_PREDEF
2281 +# define __DIET_PAGE_SHIFT __DIET_PAGE_SHIFT_PREDEF
2284 +#endif /* H_DIETLIBC_DIETPAGESIZE_H */
2285 diff -urN -x .git dietlibc-0.33/dietuglyweaks.h dietlibc/dietuglyweaks.h
2286 --- dietlibc-0.33/dietuglyweaks.h 2004-06-30 05:52:30.000000000 +0000
2287 +++ dietlibc/dietuglyweaks.h 2015-01-01 12:14:43.461605562 +0000
2289 /* if you change something here ... KNOW what you're doing !
2290 * it'll effect ALL platforms ! */
2295 +.type \name,@function
2300 +.type \name,@function
2306 .type \name,function
2308 .type \name,function
2313 DEF_W __fflush_stderr
2314 DEF_W __fflush_stdin
2315 diff -urN -x .git dietlibc-0.33/dietunaligned.h dietlibc/dietunaligned.h
2316 --- dietlibc-0.33/dietunaligned.h 1970-01-01 00:00:00.000000000 +0000
2317 +++ dietlibc/dietunaligned.h 2015-01-01 12:14:43.461605562 +0000
2319 +#ifndef H_DIETLIBC_UNALIGNED_H
2320 +#define H_DIETLIBC_UNALIGNED_H
2322 +#include <string.h>
2323 +#include <inttypes.h>
2325 +#define read_unaligned(_src) \
2328 + __typeof__(*(_src)) a; \
2329 + } __attribute__((__packed__)) *_tmp = (void *)(_src); \
2333 +#define read_unaligned_s(_src, _type, _attr) \
2334 + read_unaligned((__typeof__(&((_type *)(0))->_attr))( \
2335 + (uintptr_t)(_src) + \
2336 + __builtin_offsetof(_type, _attr))) \
2339 +#define write_unaligned(_v, _dst) \
2342 + __typeof__(*(_dst)) a; \
2343 + } __attribute__((__packed__)) *_tmp = (void *)(_dst); \
2347 +#define write_unaligned_s(_v, _dst, _type, _attr) \
2348 + write_unaligned(_v, \
2349 + (__typeof__(&((_type *)(0))->_attr))( \
2350 + (uintptr_t)(_dst) + \
2351 + __builtin_offsetof(_type, _attr))) \
2353 +#endif /* H_DIETLIBC_UNALIGNED_H */
2354 diff -urN -x .git dietlibc-0.33/dynlinker/ldso_start.S dietlibc/dynlinker/ldso_start.S
2355 --- dietlibc-0.33/dynlinker/ldso_start.S 2007-03-09 13:42:12.000000000 +0000
2356 +++ dietlibc/dynlinker/ldso_start.S 2015-01-01 12:14:43.464938896 +0000
2361 +/* __elfinfo must follow __environ immediately */
2364 +#if __WORDSIZE == 64
2373 diff -urN -x .git dietlibc-0.33/dyn_start.c dietlibc/dyn_start.c
2374 --- dietlibc-0.33/dyn_start.c 2008-05-06 17:18:34.000000000 +0000
2375 +++ dietlibc/dyn_start.c 2015-01-01 12:14:43.464938896 +0000
2377 __deregister_frame_info(__EH_FRAME_BEGIN__);
2380 -#ifdef WANT_STACKGAP
2381 -int stackgap(int argc,char* argv[],char* envp[]);
2384 #ifndef __DYN_LIB_SHARED
2385 /* pre main, post _start */
2386 extern __attribute__((section(".init"))) void _init(void);
2388 int _dyn_start(int argc, char **argv, char **envp, structor dl_init);
2389 int _dyn_start(int argc, char **argv, char **envp, structor dl_init)
2391 - int main(int argc, char **argv, char **envp);
2392 + int CALL_IN_STARTCODE(int argc, char **argv, char **envp);
2395 /* GT: segfaults on arm, don't know why (for now) */
2397 __register_frame_info(__EH_FRAME_BEGIN__, &ob);
2400 -#ifdef WANT_STACKGAP
2401 - return stackgap(argc, argv, envp);
2403 - return main(argc, argv, envp);
2405 + return CALL_IN_STARTCODE(argc, argv, envp);
2409 diff -urN -x .git dietlibc-0.33/FAQ dietlibc/FAQ
2410 --- dietlibc-0.33/FAQ 2010-11-09 18:38:34.000000000 +0000
2411 +++ dietlibc/FAQ 2015-01-01 12:14:43.451605563 +0000
2413 code. Unfortunately, these options have been renamed on gcc 3. You
2414 can fix this by creating a file ~/.diet/gcc containing this line:
2416 - -Os -fomit-frame-pointer -falign-jumps=1 -falign-loops=1 -mpreferred-stack-boundary=2
2417 + -Os -fomit-frame-pointer -falign-jumps=1 -falign-loops=1 -mpreferred-stack-boundary=4
2419 If you get this options not for diet -Os gcc but for diet -Os
2420 i386-linux-gcc, put this in ~/.diet/i386-linux-gcc instead.
2421 diff -urN -x .git dietlibc-0.33/findcflags.sh dietlibc/findcflags.sh
2422 --- dietlibc-0.33/findcflags.sh 2005-05-08 15:33:38.000000000 +0000
2423 +++ dietlibc/findcflags.sh 2015-01-01 12:14:43.464938896 +0000
2426 2.9*) echo -march=i386 -Os -fomit-frame-pointer -malign-functions=1 -malign-jumps=1 -malign-loops=1 -mpreferred-stack-boundary=2 ;;
2427 3.0*) echo -march=i386 -Os -fomit-frame-pointer -malign-functions=1 -malign-jumps=1 -malign-loops=1 -mpreferred-stack-boundary=2 ;;
2428 - [34]*) echo -Os -fomit-frame-pointer -falign-functions=1 -falign-jumps=1 -falign-loops=1 -mpreferred-stack-boundary=2;;
2429 + [34]*) echo -Os -fomit-frame-pointer -falign-functions=1 -falign-jumps=1 -falign-loops=1 -mpreferred-stack-boundary=4;;
2430 *) echo -O2 -pipe -fomit-frame-pointer ;;
2432 diff -urN -x .git dietlibc-0.33/.gitignore dietlibc/.gitignore
2433 --- dietlibc-0.33/.gitignore 1970-01-01 00:00:00.000000000 +0000
2434 +++ dietlibc/.gitignore 2015-01-01 12:14:43.451605563 +0000
2437 +/include/errno_definition.h
2438 diff -urN -x .git dietlibc-0.33/i386/accept4.S dietlibc/i386/accept4.S
2439 --- dietlibc-0.33/i386/accept4.S 1970-01-01 00:00:00.000000000 +0000
2440 +++ dietlibc/i386/accept4.S 2015-01-01 12:14:43.464938896 +0000
2442 +#include <linuxnet.h>
2443 +#include <syscalls.h>
2445 +__socketcall(accept4,ACCEPT4)
2446 diff -urN -x .git dietlibc-0.33/i386/dyn_syscalls.S dietlibc/i386/dyn_syscalls.S
2447 --- dietlibc-0.33/i386/dyn_syscalls.S 2012-01-24 18:24:24.000000000 +0000
2448 +++ dietlibc/i386/dyn_syscalls.S 2015-01-01 12:14:43.464938896 +0000
2450 #include "../syscalls.s/n_sigpending.S"
2451 #include "../syscalls.s/n_sigprocmask.S"
2452 #include "../syscalls.s/n_sigsuspend.S"
2453 -#include "../syscalls.s/nice.S"
2454 #include "../syscalls.s/pause.S"
2455 #include "../syscalls.s/personality.S"
2456 #include "../syscalls.s/query_module.S"
2457 diff -urN -x .git dietlibc-0.33/i386/getcontext.S dietlibc/i386/getcontext.S
2458 --- dietlibc-0.33/i386/getcontext.S 1970-01-01 00:00:00.000000000 +0000
2459 +++ dietlibc/i386/getcontext.S 2015-01-01 12:14:43.464938896 +0000
2461 +#include "syscalls.h"
2465 +.type getcontext,@function
2466 +/* store current CPU context into struct ucontext* */
2468 + movl 4(%esp),%eax /* load ucontext* */
2469 + /* the registers are in uc_mcontext, which starts at offset 20 */
2474 + movl %edi,36(%eax)
2475 + movl %esi,40(%eax)
2476 + movl %ebp,44(%eax)
2477 + /* skip esp until we stored ecx */
2478 + movl %ebx,52(%eax)
2479 + movl %edx,56(%eax)
2480 + movl %ecx,60(%eax)
2481 + lea 4(%esp),%ecx /* store esp+4 to esp */
2483 + movl $0,64(%eax) /* eax */
2484 + /* not touching trapno and err, no idea what do store there */
2486 + movl %ecx,76(%eax) /* store return value from stack into eip of struct */
2489 + /* 88: esp_at_signal */
2492 + lea 236(%eax),%ecx
2493 + movl %ecx,96(%eax)
2499 + lea 108(%eax),%edx
2500 + mov $__NR_sigprocmask,%eax
2505 +.size getcontext, .-getcontext
2506 diff -urN -x .git dietlibc-0.33/i386/Makefile.add dietlibc/i386/Makefile.add
2507 --- dietlibc-0.33/i386/Makefile.add 2012-01-24 18:24:24.000000000 +0000
2508 +++ dietlibc/i386/Makefile.add 2015-01-01 12:14:43.464938896 +0000
2511 M:=$(shell ./findcflags.sh $(CC))
2512 LIBOBJ+=$(OBJDIR)/__ten.o $(OBJDIR)/md5asm.o $(OBJDIR)/__restore_rt.o \
2514 +$(OBJDIR)/__CAS.o $(OBJDIR)/getcontext.o $(OBJDIR)/setcontext.o
2515 LIBMATH+=acos.o asin.o atan.o ceil.o cos.o exp.o exp10.o exp2.o expm1.o fabs.o floor.o hypot.o log.o log2.o log10.o sin.o sqrt.o copysign.o sincos.o __half.o ldexp.o ilogb.o cbrt.o log1p.o fmod.o libm2.o atan2.o tan.o
2516 LIBMATH:=$(filter-out acosh.o asinh.o atanh.o cbrt.o copysign.o exp10.o exp2.o expm1.o ilogb.o log2.o,$(LIBMATH))
2517 #CFLAGS+=-march=i386 -Os -fomit-frame-pointer -malign-functions=0 -malign-jumps=0 -malign-loops=0 -mpreferred-stack-boundary=2
2518 diff -urN -x .git dietlibc-0.33/i386/recvmmsg.S dietlibc/i386/recvmmsg.S
2519 --- dietlibc-0.33/i386/recvmmsg.S 1970-01-01 00:00:00.000000000 +0000
2520 +++ dietlibc/i386/recvmmsg.S 2015-01-01 12:14:43.468272228 +0000
2522 +#include <linuxnet.h>
2523 +#include <syscalls.h>
2525 +__socketcall(recvmmsg,RECVMMSG)
2526 diff -urN -x .git dietlibc-0.33/i386/sendmmsg.S dietlibc/i386/sendmmsg.S
2527 --- dietlibc-0.33/i386/sendmmsg.S 1970-01-01 00:00:00.000000000 +0000
2528 +++ dietlibc/i386/sendmmsg.S 2015-01-01 12:14:43.468272228 +0000
2530 +#include <linuxnet.h>
2531 +#include <syscalls.h>
2533 +__socketcall(sendmmsg,SENDMMSG)
2534 diff -urN -x .git dietlibc-0.33/i386/setcontext.S dietlibc/i386/setcontext.S
2535 --- dietlibc-0.33/i386/setcontext.S 1970-01-01 00:00:00.000000000 +0000
2536 +++ dietlibc/i386/setcontext.S 2015-01-01 12:14:43.468272228 +0000
2538 +#include "syscalls.h"
2541 +.global __setcontext_trampoline
2542 +.type __setcontext_trampoline,@function
2543 +__setcontext_trampoline:
2545 + /* fall through */
2546 +.size __setcontext_trampoline,.-__setcontext_trampoline
2549 +.type setcontext,@function
2550 +/* switch to stored CPU context from struct ucontext* */
2552 + movl 4(%esp),%eax /* load ucontext* */
2553 + /* first, load the signal mask */
2556 + movl $2,%ebx /* SIG_SETMASK */
2557 + lea 108(%eax),%ecx
2558 + movl $__NR_sigprocmask,%eax
2562 + jmp __error_unified_syscall
2564 + movl 4(%esp),%eax /* load ucontext* */
2566 + lea 236(%eax),%ecx
2569 + /* the registers are in uc_mcontext, which starts at offset 20 */
2570 + /* do not restore gs because it's thread-specific */
2574 + movl 36(%eax),%edi
2575 + movl 40(%eax),%esi
2576 + movl 44(%eax),%ebp
2577 + movl 48(%eax),%esp
2579 + movl 52(%eax),%ebx
2580 + movl 56(%eax),%edx
2581 + movl 60(%eax),%ecx
2583 + movl 76(%eax),%eax
2585 +.size setcontext, .-setcontext
2586 diff -urN -x .git dietlibc-0.33/i386/start.S dietlibc/i386/start.S
2587 --- dietlibc-0.33/i386/start.S 2012-01-24 18:24:24.000000000 +0000
2588 +++ dietlibc/i386/start.S 2015-01-01 12:14:43.468272228 +0000
2590 PIC_INIT /* non-PIC: this is an empty line */
2591 PUT_VAR %esi, environ, %ecx /* non-PIC: movl %esi,environ */
2593 -#ifdef WANT_SYSENTER
2594 +#if defined(WANT_ELFINFO) || defined(WANT_SYSENTER)
2595 /* skip environment, scan for NULL */
2600 +# ifdef WANT_ELFINFO
2601 + PUT_VAR %esi, __elfinfo, %ecx
2605 +#ifdef WANT_SYSENTER
2606 /* The ELF auxvec follows the environment, consists of key/value pairs.
2607 We are looking for key 32, which stands for the vsyscall page */
2609 diff -urN -x .git dietlibc-0.33/i386/syscalls.h dietlibc/i386/syscalls.h
2610 --- dietlibc-0.33/i386/syscalls.h 2012-01-24 18:24:24.000000000 +0000
2611 +++ dietlibc/i386/syscalls.h 2015-01-01 12:14:43.468272228 +0000
2612 @@ -339,6 +339,23 @@
2613 #define __NR_fanotify_init 338
2614 #define __NR_fanotify_mark 339
2615 #define __NR_prlimit64 340
2616 +#define __NR_name_to_handle_at 341
2617 +#define __NR_open_by_handle_at 342
2618 +#define __NR_clock_adjtime 343
2619 +#define __NR_syncfs 344
2620 +#define __NR_sendmmsg 345
2621 +#define __NR_setns 346
2622 +#define __NR_process_vm_readv 347
2623 +#define __NR_process_vm_writev 348
2624 +#define __NR_kcmp 349
2625 +#define __NR_finit_module 350
2626 +#define __NR_sched_setattr 351
2627 +#define __NR_sched_getattr 352
2628 +#define __NR_renameat2 353
2629 +#define __NR_seccomp 354
2630 +#define __NR_getrandom 355
2631 +#define __NR_memfd_create 356
2634 #define syscall_weak(name,wsym,sym) \
2638 .size sym,.Lend##sym-sym
2641 #define __socketcall(name,NAME) \
2643 .type name,@function; \
2647 .size name,.Lend##name-name
2649 -#define __socketcall(name,NAME)
2651 diff -urN -x .git dietlibc-0.33/ia64/clone.S dietlibc/ia64/clone.S
2652 --- dietlibc-0.33/ia64/clone.S 2006-06-23 17:29:33.000000000 +0000
2653 +++ dietlibc/ia64/clone.S 2015-01-01 12:14:43.468272228 +0000
2655 -/* This is untested code which probably won´t work out of the box! */
2656 +/* This is untested code which probably won't work out of the box! */
2658 #include "syscalls.h"
2661 br.call.dptk.few b0=__error_unified_syscall
2665 .size __clone, . - __clone
2666 diff -urN -x .git dietlibc-0.33/ia64/Makefile.add dietlibc/ia64/Makefile.add
2667 --- dietlibc-0.33/ia64/Makefile.add 2012-01-24 18:24:24.000000000 +0000
2668 +++ dietlibc/ia64/Makefile.add 2015-01-01 12:14:43.468272228 +0000
2670 VPATH:=ia64:syscalls.s:$(VPATH)
2671 -LIBOBJ+=$(OBJDIR)/__time.o $(OBJDIR)/__waitpid.o $(OBJDIR)/__nice.o $(OBJDIR)/__alarm.o $(OBJDIR)/__CAS.o
2672 +LIBOBJ+=$(OBJDIR)/__time.o $(OBJDIR)/__waitpid.o $(OBJDIR)/__alarm.o $(OBJDIR)/__CAS.o $(OBJDIR)/__pause.o
2673 diff -urN -x .git dietlibc-0.33/ia64/__pause.c dietlibc/ia64/__pause.c
2674 --- dietlibc-0.33/ia64/__pause.c 1970-01-01 00:00:00.000000000 +0000
2675 +++ dietlibc/ia64/__pause.c 2015-01-01 12:14:43.468272228 +0000
2677 +#include <unistd.h>
2678 +#include <signal.h>
2683 + sigemptyset(&set);
2684 + sigprocmask(SIG_BLOCK, NULL, &set);
2685 + return sigsuspend(&set);
2687 diff -urN -x .git dietlibc-0.33/ia64/start.S dietlibc/ia64/start.S
2688 --- dietlibc-0.33/ia64/start.S 2006-05-29 16:30:53.000000000 +0000
2689 +++ dietlibc/ia64/start.S 2015-01-01 12:14:43.468272228 +0000
2692 st8 [r14] = out2 /* store envp in environ */
2694 +#ifdef WANT_ELFINFO
2695 +# warning "MAKE ME IE64 CODE!"
2696 +1: ld8 r9 = [out2], 8 /* load *envp and increment it */
2697 + orr r9 = r9, r9 /* test for NULL */
2700 + adds r14 = 8, r14 /* __elfinfo = environ + 8 */
2701 + st8 [r14] = out2 /* store envp in __elfinfo */
2705 /* FIXME: dl_init parameter ??? */
2706 br.call.sptk.few rp = _dyn_start
2707 diff -urN -x .git dietlibc-0.33/ia64/syscalls.h dietlibc/ia64/syscalls.h
2708 --- dietlibc-0.33/ia64/syscalls.h 2008-12-10 20:00:58.000000000 +0000
2709 +++ dietlibc/ia64/syscalls.h 2015-01-01 12:14:43.468272228 +0000
2710 @@ -289,6 +289,34 @@
2711 #define __NR_timerfd_create 1310
2712 #define __NR_timerfd_settime 1311
2713 #define __NR_timerfd_gettime 1312
2714 +#define __NR_signalfd4 1313
2715 +#define __NR_eventfd2 1314
2716 +#define __NR_epoll_create1 1315
2717 +#define __NR_dup3 1316
2718 +#define __NR_pipe2 1317
2719 +#define __NR_inotify_init1 1318
2720 +#define __NR_preadv 1319
2721 +#define __NR_pwritev 1320
2722 +#define __NR_rt_tgsigqueueinfo 1321
2723 +#define __NR_recvmmsg 1322
2724 +#define __NR_fanotify_init 1323
2725 +#define __NR_fanotify_mark 1324
2726 +#define __NR_prlimit64 1325
2727 +#define __NR_name_to_handle_at 1326
2728 +#define __NR_open_by_handle_at 1327
2729 +#define __NR_clock_adjtime 1328
2730 +#define __NR_syncfs 1329
2731 +#define __NR_setns 1330
2732 +#define __NR_sendmmsg 1331
2733 +#define __NR_process_vm_readv 1332
2734 +#define __NR_process_vm_writev 1333
2735 +#define __NR_accept4 1334
2736 +#define __NR_finit_module 1335
2737 +#define __NR_sched_setattr 1336
2738 +#define __NR_sched_getattr 1337
2739 +#define __NR_renameat2 1338
2740 +#define __NR_getrandom 1339
2741 +#define __NR_memfd_create 1340
2743 #define syscall(name, sym) \
2745 diff -urN -x .git dietlibc-0.33/ia64/unified.S dietlibc/ia64/unified.S
2746 --- dietlibc-0.33/ia64/unified.S 2006-06-23 17:29:33.000000000 +0000
2747 +++ dietlibc/ia64/unified.S 2015-01-01 12:14:43.468272228 +0000
2751 .globl __unified_syscall
2752 -.proc __unified_syscall
2753 .globl __error_unified_syscall
2754 -.proc __error_unified_syscall
2760 .size _exit, . - _exit
2762 +.proc __unified_syscall
2768 +.endp __unified_syscall
2769 +.size __unified_syscall, . - __unified_syscall
2771 +.proc __error_unified_syscall
2772 __error_unified_syscall:
2776 #include "dietuglyweaks.h"
2779 +.endp __error_unified_syscall
2781 -.size __unified_syscall, __error_unified_syscall - __unified_syscall
2782 .size __error_unified_syscall, . - __error_unified_syscall
2783 diff -urN -x .git dietlibc-0.33/include/asm/posix_types.h dietlibc/include/asm/posix_types.h
2784 --- dietlibc-0.33/include/asm/posix_types.h 1970-01-01 00:00:00.000000000 +0000
2785 +++ dietlibc/include/asm/posix_types.h 2015-01-01 12:14:43.471605562 +0000
2787 +#ifndef _ASM_POSIX_TYPES_H
2788 +#define _ASM_POSIX_TYPES_H
2790 +typedef long __kernel_long_t;
2791 +typedef unsigned long __kernel_ulong_t;
2794 diff -urN -x .git dietlibc-0.33/include/asm/prctl.h dietlibc/include/asm/prctl.h
2795 --- dietlibc-0.33/include/asm/prctl.h 1970-01-01 00:00:00.000000000 +0000
2796 +++ dietlibc/include/asm/prctl.h 2015-01-01 12:14:43.471605562 +0000
2798 +#ifndef _ASM_PRCTL_H
2799 +#define _ASM_PRCTL_H
2801 +#if defined(__x86_64__)
2803 +#define ARCH_SET_GS 0x1001
2804 +#define ARCH_SET_FS 0x1002
2805 +#define ARCH_GET_FS 0x1003
2806 +#define ARCH_GET_GS 0x1004
2808 +#elif defined(__i386__)
2812 +#warning "need asm/prctl.h for this platform"
2816 diff -urN -x .git dietlibc-0.33/include/dirent.h dietlibc/include/dirent.h
2817 --- dietlibc-0.33/include/dirent.h 2012-11-02 11:17:28.000000000 +0000
2818 +++ dietlibc/include/dirent.h 2015-01-01 12:14:43.471605562 +0000
2821 struct dirent64 *readdir64 (DIR *__dirp) __THROW;
2822 void rewinddir (DIR *__dirp) __THROW;
2823 -void seekdir (DIR *__dirp, long int __pos) __THROW;
2824 -long int telldir (DIR *__dirp) __THROW;
2825 +void seekdir (DIR *__dirp, long __pos) __THROW;
2826 +long telldir (DIR *__dirp) __THROW;
2828 int scandir(const char *dir, struct dirent ***namelist,
2829 int (*selection)(const struct dirent *),
2830 diff -urN -x .git dietlibc-0.33/include/dlfcn.h dietlibc/include/dlfcn.h
2831 --- dietlibc-0.33/include/dlfcn.h 2005-01-31 12:53:33.000000000 +0000
2832 +++ dietlibc/include/dlfcn.h 2015-01-01 12:14:43.471605562 +0000
2837 -void *dlopen (const char *filename, int flag);
2838 -const char *dlerror(void);
2839 -void *dlsym(void *handle, const char *symbol);
2840 -int dlclose (void *handle);
2841 +void *dlopen (const char *filename, int flag) __THROWNL;
2842 +const char *dlerror(void) __THROW;
2843 +void *dlsym(void *handle, const char *symbol) __THROW;
2844 +int dlclose (void *handle) __THROWNL;
2848 diff -urN -x .git dietlibc-0.33/include/elf.h dietlibc/include/elf.h
2849 --- dietlibc-0.33/include/elf.h 2010-09-25 17:03:25.000000000 +0000
2850 +++ dietlibc/include/elf.h 2015-01-01 12:14:43.471605562 +0000
2851 @@ -954,6 +954,15 @@
2853 #define AT_SECURE 23 /* Boolean, was exec setuid-like? */
2855 +#define AT_BASE_PLATFORM 24 /* String identifying real platforms.*/
2857 +#define AT_RANDOM 25 /* Address of 16 random bytes. */
2859 +#define AT_HWCAP2 26 /* More machine-dependent hints about
2860 + processor capabilities. */
2862 +#define AT_EXECFN 31 /* Filename of executable. */
2864 /* Pointer to the global system page used for system calls and other
2866 #define AT_SYSINFO 32
2867 diff -urN -x .git dietlibc-0.33/include/endian.h dietlibc/include/endian.h
2868 --- dietlibc-0.33/include/endian.h 2006-05-29 16:30:53.000000000 +0000
2869 +++ dietlibc/include/endian.h 2015-01-01 12:14:43.471605562 +0000
2871 # define __LONG_LONG_PAIR(HI, LO) HI, LO
2874 -#if defined(__alpha__) || defined(__mips64__) || defined(__sparc_v9__) || defined(__x86_64__) || defined(__ia64__) || defined(__powerpc64__) || defined(__s390x__)
2875 +#if defined(__alpha__) || defined(__mips64__) || defined(__sparc_v9__) || defined(__ia64__) || defined(__powerpc64__) || defined(__s390x__)
2876 #define __WORDSIZE 64
2879 +#if defined(__x86_64__)
2880 +#if defined(__ILP32__)
2881 +#define __OFF_T_MATCHES_OFF64_T
2883 +#define __WORDSIZE 64
2887 #if defined(__x86_64__) || defined(__powerpc64__) || defined(__sparc_v9__)
2888 #define __WORDSIZE_COMPAT32 1
2891 #define __WORDSIZE 64
2896 +#define __OFF_T_MATCHES_OFF64_T
2898 #define __WORDSIZE 32
2901 diff -urN -x .git dietlibc-0.33/include/errno.h dietlibc/include/errno.h
2902 --- dietlibc-0.33/include/errno.h 2010-09-25 17:03:26.000000000 +0000
2903 +++ dietlibc/include/errno.h 2015-01-01 12:14:43.471605562 +0000
2904 @@ -704,11 +704,7 @@
2911 -#define errno (*__errno_location())
2913 +#include <errno_definition.h>
2915 extern int *__errno_location(void);
2917 diff -urN -x .git dietlibc-0.33/include/fcntl.h dietlibc/include/fcntl.h
2918 --- dietlibc-0.33/include/fcntl.h 2012-11-02 11:17:28.000000000 +0000
2919 +++ dietlibc/include/fcntl.h 2015-01-01 12:14:43.471605562 +0000
2922 #if defined(__i386__) || defined(__s390__) || defined(__x86_64__) || defined(__ia64__)
2924 -/* open/fcntl - O_SYNC is only implemented on blocks devices and on files
2925 - located on an ext2 file system */
2926 #define O_ACCMODE 0003
2930 #define O_APPEND 02000
2931 #define O_NONBLOCK 04000
2932 #define O_NDELAY O_NONBLOCK
2933 -#define O_SYNC 010000
2934 +#define O_DSYNC 010000
2935 #define FASYNC 020000 /* fcntl, for BSD compatibility */
2936 #define O_DIRECT 040000 /* direct disk access hint - currently ignored */
2937 #define O_LARGEFILE 0100000
2938 #define O_DIRECTORY 0200000 /* must be a directory */
2939 #define O_NOFOLLOW 0400000 /* don't follow links */
2940 #define O_NOATIME 01000000
2941 +#define O_CLOEXEC 02000000
2942 +#define O_SYNC (O_DSYNC|04000000)
2943 +#define O_PATH 010000000
2944 +#define O_TMPFILE 020000000
2946 #define F_DUPFD 0 /* dup */
2947 #define F_GETFD 1 /* get close_on_exec */
2950 #elif defined(__alpha__)
2952 -/* open/fcntl - O_SYNC is only implemented on blocks devices and on files
2953 - located on an ext2 file system */
2954 #define O_ACCMODE 0003
2957 @@ -110,13 +110,17 @@
2958 #define O_NONBLOCK 00004
2959 #define O_APPEND 00010
2960 #define O_NDELAY O_NONBLOCK
2961 -#define O_SYNC 040000
2962 +#define O_DSYNC 040000
2963 #define FASYNC 020000 /* fcntl, for BSD compatibility */
2964 #define O_DIRECTORY 0100000 /* must be a directory */
2965 #define O_NOFOLLOW 0200000 /* don't follow links */
2966 #define O_LARGEFILE 0400000 /* will be set by the kernel on every open */
2967 #define O_DIRECT 02000000 /* direct disk access - should check with OSF/1 */
2968 #define O_NOATIME 04000000
2969 +#define O_CLOEXEC 010000000
2970 +#define O_SYNC (020000000|O_DSYNC)
2971 +#define O_PATH 040000000
2972 +#define O_TMPFILE 0100000000
2974 #define F_DUPFD 0 /* dup */
2975 #define F_GETFD 1 /* get close_on_exec */
2976 @@ -167,14 +171,12 @@
2978 #elif defined(__mips__)
2980 -/* open/fcntl - O_SYNC is only implemented on blocks devices and on files
2981 - located on an ext2 file system */
2982 #define O_ACCMODE 0x0003
2983 #define O_RDONLY 0x0000
2984 #define O_WRONLY 0x0001
2985 #define O_RDWR 0x0002
2986 #define O_APPEND 0x0008
2987 -#define O_SYNC 0x0010
2988 +#define O_DSYNC 0x0010
2989 #define O_NONBLOCK 0x0080
2990 #define O_CREAT 0x0100 /* not fcntl */
2991 #define O_TRUNC 0x0200 /* not fcntl */
2992 @@ -182,10 +184,14 @@
2993 #define O_NOCTTY 0x0800 /* not fcntl */
2994 #define FASYNC 0x1000 /* fcntl, for BSD compatibility */
2995 #define O_LARGEFILE 0x2000 /* allow large file opens - currently ignored */
2996 +#define O_SYNC (0x4000|O_DSYNC)
2997 #define O_DIRECT 0x8000 /* direct disk access hint - currently ignored */
2998 #define O_DIRECTORY 0x10000 /* must be a directory */
2999 #define O_NOFOLLOW 0x20000 /* don't follow links */
3000 #define O_NOATIME 0x40000
3001 +#define O_CLOEXEC 0x80000
3002 +#define O_PATH 040000000
3003 +#define O_TMPFILE 0100000000
3005 #define O_NDELAY O_NONBLOCK
3009 #elif defined(__sparc__)
3011 -/* open/fcntl - O_SYNC is only implemented on blocks devices and on files
3012 - located on an ext2 file system */
3013 #define O_RDONLY 0x0000
3014 #define O_WRONLY 0x0001
3015 #define O_RDWR 0x0002
3017 #define O_CREAT 0x0200 /* not fcntl */
3018 #define O_TRUNC 0x0400 /* not fcntl */
3019 #define O_EXCL 0x0800 /* not fcntl */
3020 -#define O_SYNC 0x2000
3021 +#define O_DSYNC 0x2000
3022 #define O_NONBLOCK 0x4000
3023 #define O_NDELAY (0x0004 | O_NONBLOCK)
3024 #define O_NOCTTY 0x8000 /* not fcntl */
3025 @@ -286,6 +290,10 @@
3026 #define O_LARGEFILE 0x40000
3027 #define O_DIRECT 0x100000 /* direct disk access hint */
3028 #define O_NOATIME 0x200000
3029 +#define O_CLOEXEC 0x400000
3030 +#define O_SYNC (0x800000|O_DSYNC)
3031 +#define O_PATH 0x1000000
3032 +#define O_TMPFILE 0x2000000
3034 #define F_DUPFD 0 /* dup */
3035 #define F_GETFD 1 /* get close_on_exec */
3038 #elif defined(__powerpc__) || defined(__powerpc64__)
3040 -/* open/fcntl - O_SYNC is only implemented on blocks devices and on files
3041 - located on an ext2 file system */
3042 #define O_ACCMODE 0003
3045 @@ -368,13 +374,17 @@
3046 #define O_APPEND 02000
3047 #define O_NONBLOCK 04000
3048 #define O_NDELAY O_NONBLOCK
3049 -#define O_SYNC 010000
3050 +#define O_DSYNC 010000
3051 #define FASYNC 020000 /* fcntl, for BSD compatibility */
3052 #define O_DIRECTORY 040000 /* must be a directory */
3053 #define O_NOFOLLOW 0100000 /* don't follow links */
3054 #define O_LARGEFILE 0200000
3055 #define O_DIRECT 0400000 /* direct disk access hint - currently ignored */
3056 #define O_NOATIME 01000000
3057 +#define O_CLOEXEC 02000000
3058 +#define O_SYNC (O_DSYNC|04000000)
3059 +#define O_PATH 010000000
3060 +#define O_TMPFILE 020000000
3062 #define F_DUPFD 0 /* dup */
3063 #define F_GETFD 1 /* get close_on_exec */
3066 #elif defined (__arm__)
3068 -/* open/fcntl - O_SYNC is only implemented on blocks devices and on files
3069 - located on an ext2 file system */
3070 #define O_ACCMODE 0003
3073 @@ -452,13 +460,17 @@
3074 #define O_APPEND 02000
3075 #define O_NONBLOCK 04000
3076 #define O_NDELAY O_NONBLOCK
3077 -#define O_SYNC 010000
3078 +#define O_DSYNC 010000
3079 #define FASYNC 020000 /* fcntl, for BSD compatibility */
3080 #define O_DIRECTORY 040000 /* must be a directory */
3081 #define O_NOFOLLOW 0100000 /* don't follow links */
3082 #define O_DIRECT 0200000 /* direct disk access hint - currently ignored */
3083 #define O_LARGEFILE 0400000
3084 #define O_NOATIME 01000000
3085 +#define O_CLOEXEC 02000000
3086 +#define O_SYNC (O_DSYNC|04000000)
3087 +#define O_PATH 010000000
3088 +#define O_TMPFILE 020000000
3090 #define F_DUPFD 0 /* dup */
3091 #define F_GETFD 1 /* get close_on_exec */
3092 @@ -536,19 +548,24 @@
3093 #define O_EXCL 00002000 /* not fcntl */
3094 #define O_LARGEFILE 00004000
3095 #define O_ASYNC 00020000
3096 -#define O_SYNC 00100000
3097 +#define __O_SYNC 00100000
3098 #define O_NONBLOCK 00200004 /* HPUX has separate NDELAY & NONBLOCK */
3099 #define O_NDELAY O_NONBLOCK
3100 #define O_NOCTTY 00400000 /* not fcntl */
3101 #define O_DSYNC 01000000 /* HPUX only */
3102 #define O_RSYNC 02000000 /* HPUX only */
3103 #define O_NOATIME 04000000
3104 +#define O_CLOEXEC 010000000
3105 #define O_DIRECTORY 00010000
3107 #define O_DIRECT 00040000 /* direct disk access hint - currently ignored */
3108 #define O_NOFOLLOW 00000200 /* don't follow links */
3109 #define O_INVISIBLE 04000000 /* invisible I/O, for DMAPI/XDSM */
3111 +#define O_PATH 020000000
3112 +#define O_TMPFILE 040000000
3113 +#define O_SYNC (__O_SYNC|O_DSYNC)
3115 #define F_DUPFD 0 /* Duplicate file descriptor. */
3116 #define F_GETFD 1 /* Get file descriptor flags. */
3117 #define F_SETFD 2 /* Set file descriptor flags. */
3118 @@ -611,11 +628,55 @@
3124 +#define F_SETLEASE (F_LINUX_SPECIFIC_BASE + 0)
3125 +#define F_GETLEASE (F_LINUX_SPECIFIC_BASE + 1)
3128 + * Cancel a blocking posix lock; internal use only until we expose an
3129 + * asynchronous lock api to userspace:
3131 +#define F_CANCELLK (F_LINUX_SPECIFIC_BASE + 5)
3133 +/* Create a file descriptor with FD_CLOEXEC set. */
3134 +#define F_DUPFD_CLOEXEC (F_LINUX_SPECIFIC_BASE + 6)
3137 + * Request nofications on a directory.
3138 + * See below for events that may be notified.
3140 +#define F_NOTIFY (F_LINUX_SPECIFIC_BASE+2)
3143 + * Set and get of pipe page size array
3145 +#define F_SETPIPE_SZ (F_LINUX_SPECIFIC_BASE + 7)
3146 +#define F_GETPIPE_SZ (F_LINUX_SPECIFIC_BASE + 8)
3151 +#define F_ADD_SEALS (F_LINUX_SPECIFIC_BASE + 9)
3152 +#define F_GET_SEALS (F_LINUX_SPECIFIC_BASE + 10)
3157 +#define F_SEAL_SEAL 0x0001 /* prevent further seals from being set */
3158 +#define F_SEAL_SHRINK 0x0002 /* prevent file from shrinking */
3159 +#define F_SEAL_GROW 0x0004 /* prevent file from growing */
3160 +#define F_SEAL_WRITE 0x0008 /* prevent writes */
3161 +/* (1U << 31) is reserved for signed error codes */
3164 extern int fcntl (int __fd, int __cmd, ...) __THROW;
3166 extern int fcntl64 (int __fd, int __cmd, ...) __THROW;
3167 +extern int fstatat64(int dirfd, const char *pathname, struct stat *buf, int flags) __THROW;
3168 #if defined _FILE_OFFSET_BITS && _FILE_OFFSET_BITS == 64
3169 #define fcntl fcntl64
3170 +#define fstatat fstatat64
3174 @@ -628,37 +689,73 @@
3178 -#define SPLICE_F_MOVE (0x01) /* move pages instead of copying */
3179 -#define SPLICE_F_NONBLOCK (0x02) /* don't block on the pipe splicing (but */
3180 - /* we may still block on the fd we splice */
3181 - /* from/to, of course */
3182 -#define SPLICE_F_MORE (0x04) /* expect more data */
3183 -#define SPLICE_F_GIFT (0x08) /* pages passed in are a gift */
3185 + SPLICE_F_MOVE=1, /* move pages instead of copying */
3186 +#define SPLICE_F_MOVE SPLICE_F_MOVE
3187 + SPLICE_F_NONBLOCK=2, /* don't block on splicing (may still block on fd we splice */
3188 +#define SPLICE_F_NONBLOCK SPLICE_F_NONBLOCK
3189 + SPLICE_F_MORE=4, /* expect more data */
3190 +#define SPLICE_F_MORE SPLICE_F_MORE
3191 + SPLICE_F_GIFT=8 /* pages passed in are a gift */
3192 +#define SPLICE_F_GIFT SPLICE_F_GIFT
3195 -long tee(int fd_in, int fd_out, size_t len, unsigned int flags) __THROW;
3196 +ssize_t tee(int fd_in, int fd_out, size_t len, unsigned int flags) __THROW;
3198 #include <sys/uio.h>
3200 -long vmsplice(int fd, const struct iovec *iov, unsigned long nr_segs, unsigned int flags) __THROW;
3201 -long splice(int fd_in, loff_t *off_in, int fd_out, loff_t *off_out, size_t len, unsigned int flags) __THROW;
3202 +ssize_t splice(int fd_in, loff_t *off_in, int fd_out, loff_t *off_out, size_t len, unsigned int flags) __THROW;
3203 +ssize_t vmsplice(int fd, const struct iovec *iov, unsigned long nr_segs, unsigned int flags) __THROW;
3205 int sync_file_range(int fd, off64_t offset, off64_t nbytes, unsigned int flags) __THROW;
3207 #define FALLOC_FL_KEEP_SIZE 1
3209 int fallocate(int fd, int mode, loff_t offset, loff_t len) __THROW;
3212 + * Types of directory notifications that may be requested.
3214 +#define DN_ACCESS 0x00000001 /* File accessed */
3215 +#define DN_MODIFY 0x00000002 /* File modified */
3216 +#define DN_CREATE 0x00000004 /* File created */
3217 +#define DN_DELETE 0x00000008 /* File removed */
3218 +#define DN_RENAME 0x00000010 /* File renamed */
3219 +#define DN_ATTRIB 0x00000020 /* File changed attibutes */
3220 +#define DN_MULTISHOT 0x80000000 /* Don't remove notifier */
3224 -#if defined(_ATFILE_SOURCE) || ((_XOPEN_SOURCE + 0) >= 700) || ((_POSIX_C_SOURCE + 0) >= 200809L)
3225 +#define F_SETOWN_EX 15
3226 +#define F_GETOWN_EX 16
3227 +#define F_GETOWNER_UIDS 17
3229 +#define F_OFD_GETLK 36
3230 +#define F_OFD_SETLK 37
3231 +#define F_OFD_SETLKW 38
3233 +#define F_OWNER_TID 0
3234 +#define F_OWNER_PID 1
3235 +#define F_OWNER_PGRP 2
3237 +struct f_owner_ex {
3242 #define AT_FDCWD -100 /* Special value used to indicate openat should use the current working directory. */
3243 #define AT_SYMLINK_NOFOLLOW 0x100 /* Do not follow symbolic links. */
3244 #define AT_REMOVEDIR 0x200 /* Remove directory instead of unlinking file. */
3245 #define AT_SYMLINK_FOLLOW 0x400 /* Follow symbolic links. */
3246 +#define AT_NO_AUTOMOUNT 0x800 /* Suppress terminal automount traversal */
3247 +#define AT_EMPTY_PATH 0x1000 /* Allow empty relative pathname */
3249 +/* for faccessat */
3250 +#define AT_EACCESS 0x200 /* using euid, not uid for accessat */
3252 int openat(int dirfd, const char *pathname, int flags, ...) __THROW;
3253 int futimesat(int dirfd, const char *pathname, const struct timeval times[2]) __THROW;
3254 int unlinkat(int dirfd, const char *pathname, int flags) __THROW;
3257 #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE - 0) >= 600
3258 #include "linux/fadvise.h"
3259 diff -urN -x .git dietlibc-0.33/include/inttypes.h dietlibc/include/inttypes.h
3260 --- dietlibc-0.33/include/inttypes.h 2012-01-24 18:24:25.000000000 +0000
3261 +++ dietlibc/include/inttypes.h 2015-01-01 12:14:43.471605562 +0000
3263 #if __WORDSIZE == 64
3264 typedef signed long int64_t;
3265 typedef unsigned long uint64_t;
3266 -typedef signed long int intmax_t;
3267 -typedef unsigned long int uintmax_t;
3268 +typedef signed long intmax_t;
3269 +typedef unsigned long uintmax_t;
3271 __extension__ typedef signed long long int64_t;
3272 __extension__ typedef unsigned long long uint64_t;
3273 diff -urN -x .git dietlibc-0.33/include/linux/audit.h dietlibc/include/linux/audit.h
3274 --- dietlibc-0.33/include/linux/audit.h 1970-01-01 00:00:00.000000000 +0000
3275 +++ dietlibc/include/linux/audit.h 2015-01-01 12:14:43.471605562 +0000
3277 +/* audit.h -- Auditing support
3279 + * Copyright 2003-2004 Red Hat Inc., Durham, North Carolina.
3280 + * All Rights Reserved.
3282 + * This program is free software; you can redistribute it and/or modify
3283 + * it under the terms of the GNU General Public License as published by
3284 + * the Free Software Foundation; either version 2 of the License, or
3285 + * (at your option) any later version.
3287 + * This program is distributed in the hope that it will be useful,
3288 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
3289 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3290 + * GNU General Public License for more details.
3292 + * You should have received a copy of the GNU General Public License
3293 + * along with this program; if not, write to the Free Software
3294 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
3296 + * Written by Rickard E. (Rik) Faith <faith@redhat.com>
3300 +#ifndef _UAPI_LINUX_AUDIT_H_
3301 +#define _UAPI_LINUX_AUDIT_H_
3303 +#include <inttypes.h>
3305 +#include <linux/elf-em.h>
3307 +/* The netlink messages for the audit system is divided into blocks:
3308 + * 1000 - 1099 are for commanding the audit system
3309 + * 1100 - 1199 user space trusted application messages
3310 + * 1200 - 1299 messages internal to the audit daemon
3311 + * 1300 - 1399 audit event messages
3312 + * 1400 - 1499 SE Linux use
3313 + * 1500 - 1599 kernel LSPP events
3314 + * 1600 - 1699 kernel crypto events
3315 + * 1700 - 1799 kernel anomaly records
3316 + * 1800 - 1899 kernel integrity events
3317 + * 1900 - 1999 future kernel use
3318 + * 2000 is for otherwise unclassified kernel audit messages (legacy)
3319 + * 2001 - 2099 unused (kernel)
3320 + * 2100 - 2199 user space anomaly records
3321 + * 2200 - 2299 user space actions taken in response to anomalies
3322 + * 2300 - 2399 user space generated LSPP events
3323 + * 2400 - 2499 user space crypto events
3324 + * 2500 - 2999 future user space (maybe integrity labels and related events)
3326 + * Messages from 1000-1199 are bi-directional. 1200-1299 & 2100 - 2999 are
3327 + * exclusively user space. 1300-2099 is kernel --> user space
3330 +#define AUDIT_GET 1000 /* Get status */
3331 +#define AUDIT_SET 1001 /* Set status (enable/disable/auditd) */
3332 +#define AUDIT_LIST 1002 /* List syscall rules -- deprecated */
3333 +#define AUDIT_ADD 1003 /* Add syscall rule -- deprecated */
3334 +#define AUDIT_DEL 1004 /* Delete syscall rule -- deprecated */
3335 +#define AUDIT_USER 1005 /* Message from userspace -- deprecated */
3336 +#define AUDIT_LOGIN 1006 /* Define the login id and information */
3337 +#define AUDIT_WATCH_INS 1007 /* Insert file/dir watch entry */
3338 +#define AUDIT_WATCH_REM 1008 /* Remove file/dir watch entry */
3339 +#define AUDIT_WATCH_LIST 1009 /* List all file/dir watches */
3340 +#define AUDIT_SIGNAL_INFO 1010 /* Get info about sender of signal to auditd */
3341 +#define AUDIT_ADD_RULE 1011 /* Add syscall filtering rule */
3342 +#define AUDIT_DEL_RULE 1012 /* Delete syscall filtering rule */
3343 +#define AUDIT_LIST_RULES 1013 /* List syscall filtering rules */
3344 +#define AUDIT_TRIM 1014 /* Trim junk from watched tree */
3345 +#define AUDIT_MAKE_EQUIV 1015 /* Append to watched tree */
3346 +#define AUDIT_TTY_GET 1016 /* Get TTY auditing status */
3347 +#define AUDIT_TTY_SET 1017 /* Set TTY auditing status */
3348 +#define AUDIT_SET_FEATURE 1018 /* Turn an audit feature on or off */
3349 +#define AUDIT_GET_FEATURE 1019 /* Get which features are enabled */
3350 +#define AUDIT_FEATURE_CHANGE 1020 /* audit log listing feature changes */
3352 +#define AUDIT_FIRST_USER_MSG 1100 /* Userspace messages mostly uninteresting to kernel */
3353 +#define AUDIT_USER_AVC 1107 /* We filter this differently */
3354 +#define AUDIT_USER_TTY 1124 /* Non-ICANON TTY input meaning */
3355 +#define AUDIT_LAST_USER_MSG 1199
3356 +#define AUDIT_FIRST_USER_MSG2 2100 /* More user space messages */
3357 +#define AUDIT_LAST_USER_MSG2 2999
3359 +#define AUDIT_DAEMON_START 1200 /* Daemon startup record */
3360 +#define AUDIT_DAEMON_END 1201 /* Daemon normal stop record */
3361 +#define AUDIT_DAEMON_ABORT 1202 /* Daemon error stop record */
3362 +#define AUDIT_DAEMON_CONFIG 1203 /* Daemon config change */
3364 +#define AUDIT_SYSCALL 1300 /* Syscall event */
3365 +/* #define AUDIT_FS_WATCH 1301 * Deprecated */
3366 +#define AUDIT_PATH 1302 /* Filename path information */
3367 +#define AUDIT_IPC 1303 /* IPC record */
3368 +#define AUDIT_SOCKETCALL 1304 /* sys_socketcall arguments */
3369 +#define AUDIT_CONFIG_CHANGE 1305 /* Audit system configuration change */
3370 +#define AUDIT_SOCKADDR 1306 /* sockaddr copied as syscall arg */
3371 +#define AUDIT_CWD 1307 /* Current working directory */
3372 +#define AUDIT_EXECVE 1309 /* execve arguments */
3373 +#define AUDIT_IPC_SET_PERM 1311 /* IPC new permissions record type */
3374 +#define AUDIT_MQ_OPEN 1312 /* POSIX MQ open record type */
3375 +#define AUDIT_MQ_SENDRECV 1313 /* POSIX MQ send/receive record type */
3376 +#define AUDIT_MQ_NOTIFY 1314 /* POSIX MQ notify record type */
3377 +#define AUDIT_MQ_GETSETATTR 1315 /* POSIX MQ get/set attribute record type */
3378 +#define AUDIT_KERNEL_OTHER 1316 /* For use by 3rd party modules */
3379 +#define AUDIT_FD_PAIR 1317 /* audit record for pipe/socketpair */
3380 +#define AUDIT_OBJ_PID 1318 /* ptrace target */
3381 +#define AUDIT_TTY 1319 /* Input on an administrative TTY */
3382 +#define AUDIT_EOE 1320 /* End of multi-record event */
3383 +#define AUDIT_BPRM_FCAPS 1321 /* Information about fcaps increasing perms */
3384 +#define AUDIT_CAPSET 1322 /* Record showing argument to sys_capset */
3385 +#define AUDIT_MMAP 1323 /* Record showing descriptor and flags in mmap */
3386 +#define AUDIT_NETFILTER_PKT 1324 /* Packets traversing netfilter chains */
3387 +#define AUDIT_NETFILTER_CFG 1325 /* Netfilter chain modifications */
3388 +#define AUDIT_SECCOMP 1326 /* Secure Computing event */
3390 +#define AUDIT_AVC 1400 /* SE Linux avc denial or grant */
3391 +#define AUDIT_SELINUX_ERR 1401 /* Internal SE Linux Errors */
3392 +#define AUDIT_AVC_PATH 1402 /* dentry, vfsmount pair from avc */
3393 +#define AUDIT_MAC_POLICY_LOAD 1403 /* Policy file load */
3394 +#define AUDIT_MAC_STATUS 1404 /* Changed enforcing,permissive,off */
3395 +#define AUDIT_MAC_CONFIG_CHANGE 1405 /* Changes to booleans */
3396 +#define AUDIT_MAC_UNLBL_ALLOW 1406 /* NetLabel: allow unlabeled traffic */
3397 +#define AUDIT_MAC_CIPSOV4_ADD 1407 /* NetLabel: add CIPSOv4 DOI entry */
3398 +#define AUDIT_MAC_CIPSOV4_DEL 1408 /* NetLabel: del CIPSOv4 DOI entry */
3399 +#define AUDIT_MAC_MAP_ADD 1409 /* NetLabel: add LSM domain mapping */
3400 +#define AUDIT_MAC_MAP_DEL 1410 /* NetLabel: del LSM domain mapping */
3401 +#define AUDIT_MAC_IPSEC_ADDSA 1411 /* Not used */
3402 +#define AUDIT_MAC_IPSEC_DELSA 1412 /* Not used */
3403 +#define AUDIT_MAC_IPSEC_ADDSPD 1413 /* Not used */
3404 +#define AUDIT_MAC_IPSEC_DELSPD 1414 /* Not used */
3405 +#define AUDIT_MAC_IPSEC_EVENT 1415 /* Audit an IPSec event */
3406 +#define AUDIT_MAC_UNLBL_STCADD 1416 /* NetLabel: add a static label */
3407 +#define AUDIT_MAC_UNLBL_STCDEL 1417 /* NetLabel: del a static label */
3409 +#define AUDIT_FIRST_KERN_ANOM_MSG 1700
3410 +#define AUDIT_LAST_KERN_ANOM_MSG 1799
3411 +#define AUDIT_ANOM_PROMISCUOUS 1700 /* Device changed promiscuous mode */
3412 +#define AUDIT_ANOM_ABEND 1701 /* Process ended abnormally */
3413 +#define AUDIT_ANOM_LINK 1702 /* Suspicious use of file links */
3414 +#define AUDIT_INTEGRITY_DATA 1800 /* Data integrity verification */
3415 +#define AUDIT_INTEGRITY_METADATA 1801 /* Metadata integrity verification */
3416 +#define AUDIT_INTEGRITY_STATUS 1802 /* Integrity enable status */
3417 +#define AUDIT_INTEGRITY_HASH 1803 /* Integrity HASH type */
3418 +#define AUDIT_INTEGRITY_PCR 1804 /* PCR invalidation msgs */
3419 +#define AUDIT_INTEGRITY_RULE 1805 /* policy rule */
3421 +#define AUDIT_KERNEL 2000 /* Asynchronous audit record. NOT A REQUEST. */
3424 +#define AUDIT_FILTER_USER 0x00 /* Apply rule to user-generated messages */
3425 +#define AUDIT_FILTER_TASK 0x01 /* Apply rule at task creation (not syscall) */
3426 +#define AUDIT_FILTER_ENTRY 0x02 /* Apply rule at syscall entry */
3427 +#define AUDIT_FILTER_WATCH 0x03 /* Apply rule to file system watches */
3428 +#define AUDIT_FILTER_EXIT 0x04 /* Apply rule at syscall exit */
3429 +#define AUDIT_FILTER_TYPE 0x05 /* Apply rule at audit_log_start */
3431 +#define AUDIT_NR_FILTERS 6
3433 +#define AUDIT_FILTER_PREPEND 0x10 /* Prepend to front of list */
3436 +#define AUDIT_NEVER 0 /* Do not build context if rule matches */
3437 +#define AUDIT_POSSIBLE 1 /* Build context if rule matches */
3438 +#define AUDIT_ALWAYS 2 /* Generate audit record if rule matches */
3440 +/* Rule structure sizes -- if these change, different AUDIT_ADD and
3441 + * AUDIT_LIST commands must be implemented. */
3442 +#define AUDIT_MAX_FIELDS 64
3443 +#define AUDIT_MAX_KEY_LEN 256
3444 +#define AUDIT_BITMASK_SIZE 64
3445 +#define AUDIT_WORD(nr) ((uint32_t)((nr)/32))
3446 +#define AUDIT_BIT(nr) (1 << ((nr) - AUDIT_WORD(nr)*32))
3448 +#define AUDIT_SYSCALL_CLASSES 16
3449 +#define AUDIT_CLASS_DIR_WRITE 0
3450 +#define AUDIT_CLASS_DIR_WRITE_32 1
3451 +#define AUDIT_CLASS_CHATTR 2
3452 +#define AUDIT_CLASS_CHATTR_32 3
3453 +#define AUDIT_CLASS_READ 4
3454 +#define AUDIT_CLASS_READ_32 5
3455 +#define AUDIT_CLASS_WRITE 6
3456 +#define AUDIT_CLASS_WRITE_32 7
3457 +#define AUDIT_CLASS_SIGNAL 8
3458 +#define AUDIT_CLASS_SIGNAL_32 9
3460 +/* This bitmask is used to validate user input. It represents all bits that
3461 + * are currently used in an audit field constant understood by the kernel.
3462 + * If you are adding a new #define AUDIT_<whatever>, please ensure that
3463 + * AUDIT_UNUSED_BITS is updated if need be. */
3464 +#define AUDIT_UNUSED_BITS 0x07FFFC00
3466 +/* AUDIT_FIELD_COMPARE rule list */
3467 +#define AUDIT_COMPARE_UID_TO_OBJ_UID 1
3468 +#define AUDIT_COMPARE_GID_TO_OBJ_GID 2
3469 +#define AUDIT_COMPARE_EUID_TO_OBJ_UID 3
3470 +#define AUDIT_COMPARE_EGID_TO_OBJ_GID 4
3471 +#define AUDIT_COMPARE_AUID_TO_OBJ_UID 5
3472 +#define AUDIT_COMPARE_SUID_TO_OBJ_UID 6
3473 +#define AUDIT_COMPARE_SGID_TO_OBJ_GID 7
3474 +#define AUDIT_COMPARE_FSUID_TO_OBJ_UID 8
3475 +#define AUDIT_COMPARE_FSGID_TO_OBJ_GID 9
3477 +#define AUDIT_COMPARE_UID_TO_AUID 10
3478 +#define AUDIT_COMPARE_UID_TO_EUID 11
3479 +#define AUDIT_COMPARE_UID_TO_FSUID 12
3480 +#define AUDIT_COMPARE_UID_TO_SUID 13
3482 +#define AUDIT_COMPARE_AUID_TO_FSUID 14
3483 +#define AUDIT_COMPARE_AUID_TO_SUID 15
3484 +#define AUDIT_COMPARE_AUID_TO_EUID 16
3486 +#define AUDIT_COMPARE_EUID_TO_SUID 17
3487 +#define AUDIT_COMPARE_EUID_TO_FSUID 18
3489 +#define AUDIT_COMPARE_SUID_TO_FSUID 19
3491 +#define AUDIT_COMPARE_GID_TO_EGID 20
3492 +#define AUDIT_COMPARE_GID_TO_FSGID 21
3493 +#define AUDIT_COMPARE_GID_TO_SGID 22
3495 +#define AUDIT_COMPARE_EGID_TO_FSGID 23
3496 +#define AUDIT_COMPARE_EGID_TO_SGID 24
3497 +#define AUDIT_COMPARE_SGID_TO_FSGID 25
3499 +#define AUDIT_MAX_FIELD_COMPARE AUDIT_COMPARE_SGID_TO_FSGID
3502 + /* These are useful when checking the
3503 + * task structure at task creation time
3504 + * (AUDIT_PER_TASK). */
3505 +#define AUDIT_PID 0
3506 +#define AUDIT_UID 1
3507 +#define AUDIT_EUID 2
3508 +#define AUDIT_SUID 3
3509 +#define AUDIT_FSUID 4
3510 +#define AUDIT_GID 5
3511 +#define AUDIT_EGID 6
3512 +#define AUDIT_SGID 7
3513 +#define AUDIT_FSGID 8
3514 +#define AUDIT_LOGINUID 9
3515 +#define AUDIT_PERS 10
3516 +#define AUDIT_ARCH 11
3517 +#define AUDIT_MSGTYPE 12
3518 +#define AUDIT_SUBJ_USER 13 /* security label user */
3519 +#define AUDIT_SUBJ_ROLE 14 /* security label role */
3520 +#define AUDIT_SUBJ_TYPE 15 /* security label type */
3521 +#define AUDIT_SUBJ_SEN 16 /* security label sensitivity label */
3522 +#define AUDIT_SUBJ_CLR 17 /* security label clearance label */
3523 +#define AUDIT_PPID 18
3524 +#define AUDIT_OBJ_USER 19
3525 +#define AUDIT_OBJ_ROLE 20
3526 +#define AUDIT_OBJ_TYPE 21
3527 +#define AUDIT_OBJ_LEV_LOW 22
3528 +#define AUDIT_OBJ_LEV_HIGH 23
3529 +#define AUDIT_LOGINUID_SET 24
3531 + /* These are ONLY useful when checking
3532 + * at syscall exit time (AUDIT_AT_EXIT). */
3533 +#define AUDIT_DEVMAJOR 100
3534 +#define AUDIT_DEVMINOR 101
3535 +#define AUDIT_INODE 102
3536 +#define AUDIT_EXIT 103
3537 +#define AUDIT_SUCCESS 104 /* exit >= 0; value ignored */
3538 +#define AUDIT_WATCH 105
3539 +#define AUDIT_PERM 106
3540 +#define AUDIT_DIR 107
3541 +#define AUDIT_FILETYPE 108
3542 +#define AUDIT_OBJ_UID 109
3543 +#define AUDIT_OBJ_GID 110
3544 +#define AUDIT_FIELD_COMPARE 111
3546 +#define AUDIT_ARG0 200
3547 +#define AUDIT_ARG1 (AUDIT_ARG0+1)
3548 +#define AUDIT_ARG2 (AUDIT_ARG0+2)
3549 +#define AUDIT_ARG3 (AUDIT_ARG0+3)
3551 +#define AUDIT_FILTERKEY 210
3553 +#define AUDIT_NEGATE 0x80000000
3555 +/* These are the supported operators.
3559 + * 0 0 0 0 00 nonsense
3560 + * 0 0 0 1 08 & bit mask
3565 + * 1 0 0 1 48 &= bit test
3568 + * 1 1 1 1 78 all operators
3570 +#define AUDIT_BIT_MASK 0x08000000
3571 +#define AUDIT_LESS_THAN 0x10000000
3572 +#define AUDIT_GREATER_THAN 0x20000000
3573 +#define AUDIT_NOT_EQUAL 0x30000000
3574 +#define AUDIT_EQUAL 0x40000000
3575 +#define AUDIT_BIT_TEST (AUDIT_BIT_MASK|AUDIT_EQUAL)
3576 +#define AUDIT_LESS_THAN_OR_EQUAL (AUDIT_LESS_THAN|AUDIT_EQUAL)
3577 +#define AUDIT_GREATER_THAN_OR_EQUAL (AUDIT_GREATER_THAN|AUDIT_EQUAL)
3578 +#define AUDIT_OPERATORS (AUDIT_EQUAL|AUDIT_NOT_EQUAL|AUDIT_BIT_MASK)
3592 +/* Status symbols */
3594 +#define AUDIT_STATUS_ENABLED 0x0001
3595 +#define AUDIT_STATUS_FAILURE 0x0002
3596 +#define AUDIT_STATUS_PID 0x0004
3597 +#define AUDIT_STATUS_RATE_LIMIT 0x0008
3598 +#define AUDIT_STATUS_BACKLOG_LIMIT 0x0010
3599 + /* Failure-to-log actions */
3600 +#define AUDIT_FAIL_SILENT 0
3601 +#define AUDIT_FAIL_PRINTK 1
3602 +#define AUDIT_FAIL_PANIC 2
3604 +/* distinguish syscall tables */
3605 +#define __AUDIT_ARCH_64BIT 0x80000000
3606 +#define __AUDIT_ARCH_LE 0x40000000
3607 +#define AUDIT_ARCH_ALPHA (EM_ALPHA|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
3608 +#define AUDIT_ARCH_ARM (EM_ARM|__AUDIT_ARCH_LE)
3609 +#define AUDIT_ARCH_ARMEB (EM_ARM)
3610 +#define AUDIT_ARCH_CRIS (EM_CRIS|__AUDIT_ARCH_LE)
3611 +#define AUDIT_ARCH_FRV (EM_FRV)
3612 +#define AUDIT_ARCH_I386 (EM_386|__AUDIT_ARCH_LE)
3613 +#define AUDIT_ARCH_IA64 (EM_IA_64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
3614 +#define AUDIT_ARCH_M32R (EM_M32R)
3615 +#define AUDIT_ARCH_M68K (EM_68K)
3616 +#define AUDIT_ARCH_MIPS (EM_MIPS)
3617 +#define AUDIT_ARCH_MIPSEL (EM_MIPS|__AUDIT_ARCH_LE)
3618 +#define AUDIT_ARCH_MIPS64 (EM_MIPS|__AUDIT_ARCH_64BIT)
3619 +#define AUDIT_ARCH_MIPSEL64 (EM_MIPS|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
3620 +#define AUDIT_ARCH_OPENRISC (EM_OPENRISC)
3621 +#define AUDIT_ARCH_PARISC (EM_PARISC)
3622 +#define AUDIT_ARCH_PARISC64 (EM_PARISC|__AUDIT_ARCH_64BIT)
3623 +#define AUDIT_ARCH_PPC (EM_PPC)
3624 +#define AUDIT_ARCH_PPC64 (EM_PPC64|__AUDIT_ARCH_64BIT)
3625 +#define AUDIT_ARCH_S390 (EM_S390)
3626 +#define AUDIT_ARCH_S390X (EM_S390|__AUDIT_ARCH_64BIT)
3627 +#define AUDIT_ARCH_SH (EM_SH)
3628 +#define AUDIT_ARCH_SHEL (EM_SH|__AUDIT_ARCH_LE)
3629 +#define AUDIT_ARCH_SH64 (EM_SH|__AUDIT_ARCH_64BIT)
3630 +#define AUDIT_ARCH_SHEL64 (EM_SH|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
3631 +#define AUDIT_ARCH_SPARC (EM_SPARC)
3632 +#define AUDIT_ARCH_SPARC64 (EM_SPARCV9|__AUDIT_ARCH_64BIT)
3633 +#define AUDIT_ARCH_X86_64 (EM_X86_64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
3635 +#define AUDIT_PERM_EXEC 1
3636 +#define AUDIT_PERM_WRITE 2
3637 +#define AUDIT_PERM_READ 4
3638 +#define AUDIT_PERM_ATTR 8
3640 +/* MAX_AUDIT_MESSAGE_LENGTH is set in audit:lib/libaudit.h as:
3641 + * 8970 // PATH_MAX*2+CONTEXT_SIZE*2+11+256+1
3642 + * max header+body+tailer: 44 + 29 + 32 + 262 + 7 + pad
3644 +#define AUDIT_MESSAGE_TEXT_MAX 8560
3646 +struct audit_status {
3647 + uint32_t mask; /* Bit mask for valid entries */
3648 + uint32_t enabled; /* 1 = enabled, 0 = disabled */
3649 + uint32_t failure; /* Failure-to-log action */
3650 + uint32_t pid; /* pid of auditd process */
3651 + uint32_t rate_limit; /* messages rate limit (per second) */
3652 + uint32_t backlog_limit; /* waiting messages limit */
3653 + uint32_t lost; /* messages lost */
3654 + uint32_t backlog; /* messages waiting in queue */
3657 +struct audit_features {
3658 +#define AUDIT_FEATURE_VERSION 1
3660 + uint32_t mask; /* which bits we are dealing with */
3661 + uint32_t features; /* which feature to enable/disable */
3662 + uint32_t lock; /* which features to lock */
3665 +#define AUDIT_FEATURE_ONLY_UNSET_LOGINUID 0
3666 +#define AUDIT_FEATURE_LOGINUID_IMMUTABLE 1
3667 +#define AUDIT_LAST_FEATURE AUDIT_FEATURE_LOGINUID_IMMUTABLE
3669 +#define audit_feature_valid(x) ((x) >= 0 && (x) <= AUDIT_LAST_FEATURE)
3670 +#define AUDIT_FEATURE_TO_MASK(x) (1 << ((x) & 31)) /* mask for uint32_t */
3672 +struct audit_tty_status {
3673 + uint32_t enabled; /* 1 = enabled, 0 = disabled */
3674 + uint32_t log_passwd; /* 1 = enabled, 0 = disabled */
3677 +#define AUDIT_UID_UNSET (unsigned int)-1
3679 +/* audit_rule_data supports filter rules with both integer and string
3680 + * fields. It corresponds with AUDIT_ADD_RULE, AUDIT_DEL_RULE and
3681 + * AUDIT_LIST_RULES requests.
3683 +struct audit_rule_data {
3684 + uint32_t flags; /* AUDIT_PER_{TASK,CALL}, AUDIT_PREPEND */
3685 + uint32_t action; /* AUDIT_NEVER, AUDIT_POSSIBLE, AUDIT_ALWAYS */
3686 + uint32_t field_count;
3687 + uint32_t mask[AUDIT_BITMASK_SIZE]; /* syscall(s) affected */
3688 + uint32_t fields[AUDIT_MAX_FIELDS];
3689 + uint32_t values[AUDIT_MAX_FIELDS];
3690 + uint32_t fieldflags[AUDIT_MAX_FIELDS];
3691 + uint32_t buflen; /* total length of string fields */
3692 + char buf[0]; /* string fields buffer */
3695 +/* audit_rule is supported to maintain backward compatibility with
3696 + * userspace. It supports integer fields only and corresponds to
3697 + * AUDIT_ADD, AUDIT_DEL and AUDIT_LIST requests.
3699 +struct audit_rule { /* for AUDIT_LIST, AUDIT_ADD, and AUDIT_DEL */
3700 + uint32_t flags; /* AUDIT_PER_{TASK,CALL}, AUDIT_PREPEND */
3701 + uint32_t action; /* AUDIT_NEVER, AUDIT_POSSIBLE, AUDIT_ALWAYS */
3702 + uint32_t field_count;
3703 + uint32_t mask[AUDIT_BITMASK_SIZE];
3704 + uint32_t fields[AUDIT_MAX_FIELDS];
3705 + uint32_t values[AUDIT_MAX_FIELDS];
3708 +#endif /* _UAPI_LINUX_AUDIT_H_ */
3709 diff -urN -x .git dietlibc-0.33/include/linux/elf-em.h dietlibc/include/linux/elf-em.h
3710 --- dietlibc-0.33/include/linux/elf-em.h 1970-01-01 00:00:00.000000000 +0000
3711 +++ dietlibc/include/linux/elf-em.h 2015-01-01 12:14:43.471605562 +0000
3713 +#ifndef _LINUX_ELF_EM_H
3714 +#define _LINUX_ELF_EM_H
3716 +/* These constants define the various ELF target machines */
3723 +#define EM_486 6 /* Perhaps disused */
3725 +#define EM_MIPS 8 /* MIPS R3000 (officially, big-endian only) */
3726 + /* Next two are historical and binaries and
3727 + modules of these types will be rejected by
3729 +#define EM_MIPS_RS3_LE 10 /* MIPS R3000 little-endian */
3730 +#define EM_MIPS_RS4_BE 10 /* MIPS R4000 big-endian */
3732 +#define EM_PARISC 15 /* HPPA */
3733 +#define EM_SPARC32PLUS 18 /* Sun's "v8plus" */
3734 +#define EM_PPC 20 /* PowerPC */
3735 +#define EM_PPC64 21 /* PowerPC64 */
3736 +#define EM_SPU 23 /* Cell BE SPU */
3737 +#define EM_ARM 40 /* ARM 32 bit */
3738 +#define EM_SH 42 /* SuperH */
3739 +#define EM_SPARCV9 43 /* SPARC v9 64-bit */
3740 +#define EM_IA_64 50 /* HP/Intel IA-64 */
3741 +#define EM_X86_64 62 /* AMD x86-64 */
3742 +#define EM_S390 22 /* IBM S/390 */
3743 +#define EM_CRIS 76 /* Axis Communications 32-bit embedded processor */
3744 +#define EM_V850 87 /* NEC v850 */
3745 +#define EM_M32R 88 /* Renesas M32R */
3746 +#define EM_MN10300 89 /* Panasonic/MEI MN10300, AM33 */
3747 +#define EM_BLACKFIN 106 /* ADI Blackfin Processor */
3748 +#define EM_TI_C6000 140 /* TI C6X DSPs */
3749 +#define EM_AARCH64 183 /* ARM 64 bit */
3750 +#define EM_FRV 0x5441 /* Fujitsu FR-V */
3751 +#define EM_AVR32 0x18ad /* Atmel AVR32 */
3754 + * This is an interim value that we will use until the committee comes
3755 + * up with a final number.
3757 +#define EM_ALPHA 0x9026
3759 +/* Bogus old v850 magic number, used by old tools. */
3760 +#define EM_CYGNUS_V850 0x9080
3761 +/* Bogus old m32r magic number, used by old tools. */
3762 +#define EM_CYGNUS_M32R 0x9041
3763 +/* This is the old interim value for S/390 architecture */
3764 +#define EM_S390_OLD 0xA390
3765 +/* Also Panasonic/MEI MN10300, AM33 */
3766 +#define EM_CYGNUS_MN10300 0xbeef
3769 +#endif /* _LINUX_ELF_EM_H */
3770 diff -urN -x .git dietlibc-0.33/include/linux/filter.h dietlibc/include/linux/filter.h
3771 --- dietlibc-0.33/include/linux/filter.h 1970-01-01 00:00:00.000000000 +0000
3772 +++ dietlibc/include/linux/filter.h 2015-01-01 12:14:43.471605562 +0000
3775 + * Linux Socket Filter Data Structures
3778 +#ifndef _UAPI__LINUX_FILTER_H__
3779 +#define _UAPI__LINUX_FILTER_H__
3781 +#include <inttypes.h>
3785 + * Current version of the filter code architecture.
3787 +#define BPF_MAJOR_VERSION 1
3788 +#define BPF_MINOR_VERSION 1
3791 + * Try and keep these values and structures similar to BSD, especially
3792 + * the BPF code definitions which need to match so you can share filters
3795 +struct sock_filter { /* Filter block */
3796 + uint16_t code; /* Actual filter code */
3797 + uint8_t jt; /* Jump true */
3798 + uint8_t jf; /* Jump false */
3799 + uint32_t k; /* Generic multiuse field */
3802 +struct sock_fprog { /* Required for SO_ATTACH_FILTER. */
3803 + unsigned short len; /* Number of filter blocks */
3804 + struct sock_filter *filter;
3808 + * Instruction classes
3811 +#define BPF_CLASS(code) ((code) & 0x07)
3812 +#define BPF_LD 0x00
3813 +#define BPF_LDX 0x01
3814 +#define BPF_ST 0x02
3815 +#define BPF_STX 0x03
3816 +#define BPF_ALU 0x04
3817 +#define BPF_JMP 0x05
3818 +#define BPF_RET 0x06
3819 +#define BPF_MISC 0x07
3821 +/* ld/ldx fields */
3822 +#define BPF_SIZE(code) ((code) & 0x18)
3826 +#define BPF_MODE(code) ((code) & 0xe0)
3827 +#define BPF_IMM 0x00
3828 +#define BPF_ABS 0x20
3829 +#define BPF_IND 0x40
3830 +#define BPF_MEM 0x60
3831 +#define BPF_LEN 0x80
3832 +#define BPF_MSH 0xa0
3834 +/* alu/jmp fields */
3835 +#define BPF_OP(code) ((code) & 0xf0)
3836 +#define BPF_ADD 0x00
3837 +#define BPF_SUB 0x10
3838 +#define BPF_MUL 0x20
3839 +#define BPF_DIV 0x30
3840 +#define BPF_OR 0x40
3841 +#define BPF_AND 0x50
3842 +#define BPF_LSH 0x60
3843 +#define BPF_RSH 0x70
3844 +#define BPF_NEG 0x80
3845 +#define BPF_MOD 0x90
3846 +#define BPF_XOR 0xa0
3848 +#define BPF_JA 0x00
3849 +#define BPF_JEQ 0x10
3850 +#define BPF_JGT 0x20
3851 +#define BPF_JGE 0x30
3852 +#define BPF_JSET 0x40
3853 +#define BPF_SRC(code) ((code) & 0x08)
3857 +/* ret - BPF_K and BPF_X also apply */
3858 +#define BPF_RVAL(code) ((code) & 0x18)
3862 +#define BPF_MISCOP(code) ((code) & 0xf8)
3863 +#define BPF_TAX 0x00
3864 +#define BPF_TXA 0x80
3866 +#ifndef BPF_MAXINSNS
3867 +#define BPF_MAXINSNS 4096
3871 + * Macros for filter block array initializers.
3874 +#define BPF_STMT(code, k) { (unsigned short)(code), 0, 0, k }
3877 +#define BPF_JUMP(code, k, jt, jf) { (unsigned short)(code), jt, jf, k }
3881 + * Number of scratch memory words for: BPF_ST and BPF_STX
3883 +#define BPF_MEMWORDS 16
3885 +/* RATIONALE. Negative offsets are invalid in BPF.
3886 + We use them to reference ancillary data.
3887 + Unlike introduction new instructions, it does not break
3888 + existing compilers/optimizers.
3890 +#define SKF_AD_OFF (-0x1000)
3891 +#define SKF_AD_PROTOCOL 0
3892 +#define SKF_AD_PKTTYPE 4
3893 +#define SKF_AD_IFINDEX 8
3894 +#define SKF_AD_NLATTR 12
3895 +#define SKF_AD_NLATTR_NEST 16
3896 +#define SKF_AD_MARK 20
3897 +#define SKF_AD_QUEUE 24
3898 +#define SKF_AD_HATYPE 28
3899 +#define SKF_AD_RXHASH 32
3900 +#define SKF_AD_CPU 36
3901 +#define SKF_AD_ALU_XOR_X 40
3902 +#define SKF_AD_VLAN_TAG 44
3903 +#define SKF_AD_VLAN_TAG_PRESENT 48
3904 +#define SKF_AD_PAY_OFFSET 52
3905 +#define SKF_AD_MAX 56
3906 +#define SKF_NET_OFF (-0x100000)
3907 +#define SKF_LL_OFF (-0x200000)
3910 +#endif /* _UAPI__LINUX_FILTER_H__ */
3911 diff -urN -x .git dietlibc-0.33/include/linux/prctl.h dietlibc/include/linux/prctl.h
3912 --- dietlibc-0.33/include/linux/prctl.h 1970-01-01 00:00:00.000000000 +0000
3913 +++ dietlibc/include/linux/prctl.h 2015-01-01 12:14:43.474938895 +0000
3915 +#ifndef _LINUX_PRCTL_H
3916 +#define _LINUX_PRCTL_H
3918 +/* Values to pass as first argument to prctl() */
3920 +#define PR_SET_PDEATHSIG 1 /* Second arg is a signal */
3921 +#define PR_GET_PDEATHSIG 2 /* Second arg is a ptr to return the signal */
3923 +/* Get/set current->mm->dumpable */
3924 +#define PR_GET_DUMPABLE 3
3925 +#define PR_SET_DUMPABLE 4
3927 +/* Get/set unaligned access control bits (if meaningful) */
3928 +#define PR_GET_UNALIGN 5
3929 +#define PR_SET_UNALIGN 6
3930 +# define PR_UNALIGN_NOPRINT 1 /* silently fix up unaligned user accesses */
3931 +# define PR_UNALIGN_SIGBUS 2 /* generate SIGBUS on unaligned user access */
3933 +/* Get/set whether or not to drop capabilities on setuid() away from
3934 + * uid 0 (as per security/commoncap.c) */
3935 +#define PR_GET_KEEPCAPS 7
3936 +#define PR_SET_KEEPCAPS 8
3938 +/* Get/set floating-point emulation control bits (if meaningful) */
3939 +#define PR_GET_FPEMU 9
3940 +#define PR_SET_FPEMU 10
3941 +# define PR_FPEMU_NOPRINT 1 /* silently emulate fp operations accesses */
3942 +# define PR_FPEMU_SIGFPE 2 /* don't emulate fp operations, send SIGFPE instead */
3944 +/* Get/set floating-point exception mode (if meaningful) */
3945 +#define PR_GET_FPEXC 11
3946 +#define PR_SET_FPEXC 12
3947 +# define PR_FP_EXC_SW_ENABLE 0x80 /* Use FPEXC for FP exception enables */
3948 +# define PR_FP_EXC_DIV 0x010000 /* floating point divide by zero */
3949 +# define PR_FP_EXC_OVF 0x020000 /* floating point overflow */
3950 +# define PR_FP_EXC_UND 0x040000 /* floating point underflow */
3951 +# define PR_FP_EXC_RES 0x080000 /* floating point inexact result */
3952 +# define PR_FP_EXC_INV 0x100000 /* floating point invalid operation */
3953 +# define PR_FP_EXC_DISABLED 0 /* FP exceptions disabled */
3954 +# define PR_FP_EXC_NONRECOV 1 /* async non-recoverable exc. mode */
3955 +# define PR_FP_EXC_ASYNC 2 /* async recoverable exception mode */
3956 +# define PR_FP_EXC_PRECISE 3 /* precise exception mode */
3958 +/* Get/set whether we use statistical process timing or accurate timestamp
3959 + * based process timing */
3960 +#define PR_GET_TIMING 13
3961 +#define PR_SET_TIMING 14
3962 +# define PR_TIMING_STATISTICAL 0 /* Normal, traditional,
3963 + statistical process timing */
3964 +# define PR_TIMING_TIMESTAMP 1 /* Accurate timestamp based
3967 +#define PR_SET_NAME 15 /* Set process name */
3968 +#define PR_GET_NAME 16 /* Get process name */
3970 +/* Get/set process endian */
3971 +#define PR_GET_ENDIAN 19
3972 +#define PR_SET_ENDIAN 20
3973 +# define PR_ENDIAN_BIG 0
3974 +# define PR_ENDIAN_LITTLE 1 /* True little endian mode */
3975 +# define PR_ENDIAN_PPC_LITTLE 2 /* "PowerPC" pseudo little endian */
3977 +/* Get/set process seccomp mode */
3978 +#define PR_GET_SECCOMP 21
3979 +#define PR_SET_SECCOMP 22
3981 +/* Get/set the capability bounding set (as per security/commoncap.c) */
3982 +#define PR_CAPBSET_READ 23
3983 +#define PR_CAPBSET_DROP 24
3985 +/* Get/set the process' ability to use the timestamp counter instruction */
3986 +#define PR_GET_TSC 25
3987 +#define PR_SET_TSC 26
3988 +# define PR_TSC_ENABLE 1 /* allow the use of the timestamp counter */
3989 +# define PR_TSC_SIGSEGV 2 /* throw a SIGSEGV instead of reading the TSC */
3991 +/* Get/set securebits (as per security/commoncap.c) */
3992 +#define PR_GET_SECUREBITS 27
3993 +#define PR_SET_SECUREBITS 28
3996 + * Get/set the timerslack as used by poll/select/nanosleep
3997 + * A value of 0 means "use default"
3999 +#define PR_SET_TIMERSLACK 29
4000 +#define PR_GET_TIMERSLACK 30
4002 +#define PR_TASK_PERF_EVENTS_DISABLE 31
4003 +#define PR_TASK_PERF_EVENTS_ENABLE 32
4006 + * Set early/late kill mode for hwpoison memory corruption.
4007 + * This influences when the process gets killed on a memory corruption.
4009 +#define PR_MCE_KILL 33
4010 +# define PR_MCE_KILL_CLEAR 0
4011 +# define PR_MCE_KILL_SET 1
4013 +# define PR_MCE_KILL_LATE 0
4014 +# define PR_MCE_KILL_EARLY 1
4015 +# define PR_MCE_KILL_DEFAULT 2
4017 +#define PR_MCE_KILL_GET 34
4020 + * Tune up process memory map specifics.
4022 +#define PR_SET_MM 35
4023 +# define PR_SET_MM_START_CODE 1
4024 +# define PR_SET_MM_END_CODE 2
4025 +# define PR_SET_MM_START_DATA 3
4026 +# define PR_SET_MM_END_DATA 4
4027 +# define PR_SET_MM_START_STACK 5
4028 +# define PR_SET_MM_START_BRK 6
4029 +# define PR_SET_MM_BRK 7
4030 +# define PR_SET_MM_ARG_START 8
4031 +# define PR_SET_MM_ARG_END 9
4032 +# define PR_SET_MM_ENV_START 10
4033 +# define PR_SET_MM_ENV_END 11
4034 +# define PR_SET_MM_AUXV 12
4035 +# define PR_SET_MM_EXE_FILE 13
4038 + * Set specific pid that is allowed to ptrace the current task.
4039 + * A value of 0 mean "no process".
4041 +#define PR_SET_PTRACER 0x59616d61
4042 +# define PR_SET_PTRACER_ANY ((unsigned long)-1)
4044 +#define PR_SET_CHILD_SUBREAPER 36
4045 +#define PR_GET_CHILD_SUBREAPER 37
4048 + * If no_new_privs is set, then operations that grant new privileges (i.e.
4049 + * execve) will either fail or not grant them. This affects suid/sgid,
4050 + * file capabilities, and LSMs.
4052 + * Operations that merely manipulate or drop existing privileges (setresuid,
4053 + * capset, etc.) will still work. Drop those privileges if you want them gone.
4055 + * Changing LSM security domain is considered a new privilege. So, for example,
4056 + * asking selinux for a specific new context (e.g. with runcon) will result
4057 + * in execve returning -EPERM.
4059 + * See Documentation/prctl/no_new_privs.txt for more details.
4061 +#define PR_SET_NO_NEW_PRIVS 38
4062 +#define PR_GET_NO_NEW_PRIVS 39
4064 +#define PR_GET_TID_ADDRESS 40
4066 +#endif /* _LINUX_PRCTL_H */
4067 diff -urN -x .git dietlibc-0.33/include/linux/random.h dietlibc/include/linux/random.h
4068 --- dietlibc-0.33/include/linux/random.h 1970-01-01 00:00:00.000000000 +0000
4069 +++ dietlibc/include/linux/random.h 2015-01-01 12:14:43.474938895 +0000
4072 + * include/linux/random.h
4074 + * Include file for the random number generator.
4077 +#ifndef _LINUX_RANDOM_H
4078 +#define _LINUX_RANDOM_H
4080 +#include <sys/cdefs.h>
4084 +#ifndef GRND_NONBLOCK
4087 +#define GRND_NONBLOCK GRND_NONBLOCK
4089 +#define GRND_RANDOM GRND_RANDOM
4092 +int getrandom(void* buf, size_t buflen, unsigned int flags) __THROW;
4097 +#endif /* _LINUX_RANDOM_H */
4098 diff -urN -x .git dietlibc-0.33/include/linux/seccomp.h dietlibc/include/linux/seccomp.h
4099 --- dietlibc-0.33/include/linux/seccomp.h 1970-01-01 00:00:00.000000000 +0000
4100 +++ dietlibc/include/linux/seccomp.h 2015-01-01 12:14:43.474938895 +0000
4102 +#ifndef _UAPI_LINUX_SECCOMP_H
4103 +#define _UAPI_LINUX_SECCOMP_H
4105 +#include <inttypes.h>
4107 +/* Valid values for seccomp.mode and prctl(PR_SET_SECCOMP, <mode>) */
4108 +#define SECCOMP_MODE_DISABLED 0 /* seccomp is not in use. */
4109 +#define SECCOMP_MODE_STRICT 1 /* uses hard-coded filter. */
4110 +#define SECCOMP_MODE_FILTER 2 /* uses user-supplied filter. */
4113 + * All BPF programs must return a 32-bit value.
4114 + * The bottom 16-bits are for optional return data.
4115 + * The upper 16-bits are ordered from least permissive values to most.
4117 + * The ordering ensures that a min_t() over composed return values always
4118 + * selects the least permissive choice.
4120 +#define SECCOMP_RET_KILL 0x00000000U /* kill the task immediately */
4121 +#define SECCOMP_RET_TRAP 0x00030000U /* disallow and force a SIGSYS */
4122 +#define SECCOMP_RET_ERRNO 0x00050000U /* returns an errno */
4123 +#define SECCOMP_RET_TRACE 0x7ff00000U /* pass to a tracer or disallow */
4124 +#define SECCOMP_RET_ALLOW 0x7fff0000U /* allow */
4126 +/* Masks for the return value sections. */
4127 +#define SECCOMP_RET_ACTION 0x7fff0000U
4128 +#define SECCOMP_RET_DATA 0x0000ffffU
4131 + * struct seccomp_data - the format the BPF program executes over.
4132 + * @nr: the system call number
4133 + * @arch: indicates system call convention as an AUDIT_ARCH_* value
4134 + * as defined in <linux/audit.h>.
4135 + * @instruction_pointer: at the time of the system call.
4136 + * @args: up to 6 system call arguments always stored as 64-bit values
4137 + * regardless of the architecture.
4139 +struct seccomp_data {
4142 + uint64_t instruction_pointer;
4146 +#endif /* _UAPI_LINUX_SECCOMP_H */
4147 diff -urN -x .git dietlibc-0.33/include/linux/sysinfo.h dietlibc/include/linux/sysinfo.h
4148 --- dietlibc-0.33/include/linux/sysinfo.h 1970-01-01 00:00:00.000000000 +0000
4149 +++ dietlibc/include/linux/sysinfo.h 2015-01-01 12:14:43.474938895 +0000
4151 +#ifndef _LINUX_SYSINFO_H
4152 +#define _LINUX_SYSINFO_H
4154 +#include <linux/types.h>
4156 +#define SI_LOAD_SHIFT 16
4158 + __kernel_long_t uptime; /* Seconds since boot */
4159 + __kernel_ulong_t loads[3]; /* 1, 5, and 15 minute load averages */
4160 + __kernel_ulong_t totalram; /* Total usable main memory size */
4161 + __kernel_ulong_t freeram; /* Available memory size */
4162 + __kernel_ulong_t sharedram; /* Amount of shared memory */
4163 + __kernel_ulong_t bufferram; /* Memory used by buffers */
4164 + __kernel_ulong_t totalswap; /* Total swap space size */
4165 + __kernel_ulong_t freeswap; /* swap space still available */
4166 + __u16 procs; /* Number of current processes */
4167 + __u16 pad; /* Explicit padding for m68k */
4168 + __kernel_ulong_t totalhigh; /* Total high memory size */
4169 + __kernel_ulong_t freehigh; /* Available high memory size */
4170 + __u32 mem_unit; /* Memory unit size in bytes */
4171 + char _f[20-2*sizeof(__kernel_ulong_t)-sizeof(__u32)]; /* Padding: libc5 uses this.. */
4174 +#endif /* _LINUX_SYSINFO_H */
4175 diff -urN -x .git dietlibc-0.33/include/linux/types.h dietlibc/include/linux/types.h
4176 --- dietlibc-0.33/include/linux/types.h 2001-07-30 13:34:41.000000000 +0000
4177 +++ dietlibc/include/linux/types.h 2015-01-01 12:14:43.474938895 +0000
4179 #define _LINUX_TYPES_H
4181 #include <asm/types.h>
4182 +#include <asm/posix_types.h>
4185 diff -urN -x .git dietlibc-0.33/include/netinet/tcp.h dietlibc/include/netinet/tcp.h
4186 --- dietlibc-0.33/include/netinet/tcp.h 2003-08-19 16:58:18.000000000 +0000
4187 +++ dietlibc/include/netinet/tcp.h 2015-01-01 12:14:43.474938895 +0000
4190 #include <inttypes.h>
4192 +#include <sys/socket.h> /* for sockaddr_storage */
4201 + * TCP general constants
4203 +#define TCP_MSS_DEFAULT 536U /* IPv4 (RFC1122, RFC2581) */
4204 +#define TCP_MSS_DESIRED 1220U /* IPv6 (tunneled), EDNS0 (RFC3226) */
4206 /* TCP socket options */
4207 #define TCP_NODELAY 1 /* Turn off Nagle's algorithm. */
4208 #define TCP_MAXSEG 2 /* Limit MSS */
4209 @@ -107,11 +114,25 @@
4210 #define TCP_WINDOW_CLAMP 10 /* Bound advertised window */
4211 #define TCP_INFO 11 /* Information about this connection. */
4212 #define TCP_QUICKACK 12 /* Block/reenable quick acks */
4213 +#define TCP_CONGESTION 13 /* Congestion control algorithm */
4214 +#define TCP_MD5SIG 14 /* TCP MD5 Signature (RFC2385) */
4215 +#define TCP_THIN_LINEAR_TIMEOUTS 16 /* Use linear timeouts for thin streams*/
4216 +#define TCP_THIN_DUPACK 17 /* Fast retrans. after 1 dupack */
4217 +#define TCP_USER_TIMEOUT 18 /* How long for loss retry before timeout */
4218 +#define TCP_REPAIR 19 /* TCP sock is under repair right now */
4219 +#define TCP_REPAIR_QUEUE 20
4220 +#define TCP_QUEUE_SEQ 21
4221 +#define TCP_REPAIR_OPTIONS 22
4222 +#define TCP_FASTOPEN 23 /* Enable FastOpen on listeners */
4223 +#define TCP_TIMESTAMP 24
4224 +#define TCP_NOTSENT_LOWAT 25 /* limit number of unsent bytes in write queue */
4226 #define TCPI_OPT_TIMESTAMPS 1
4227 #define TCPI_OPT_SACK 2
4228 #define TCPI_OPT_WSCALE 4
4229 #define TCPI_OPT_ECN 8
4230 +#define TCPI_OPT_ECN_SEEN 16 /* we received at least one packet with ECT */
4231 +#define TCPI_OPT_SYN_DATA 32 /* SYN-ACK acked data in SYN sent or rcvd */
4235 @@ -161,6 +182,24 @@
4236 uint32_t tcpi_snd_cwnd;
4237 uint32_t tcpi_advmss;
4238 uint32_t tcpi_reordering;
4239 + uint32_t tcpi_rcv_rtt;
4240 + uint32_t tcpi_rcv_space;
4242 + uint32_t tcpi_total_retrans;
4244 + uint64_t tcpi_pacing_rate;
4245 + uint64_t tcpi_max_pacing_rate;
4248 +/* for TCP_MD5SIG socket option */
4249 +#define TCP_MD5SIG_MAXKEYLEN 80
4251 +struct tcp_md5sig {
4252 + struct sockaddr_storage tcpm_addr; /* address associated */
4253 + uint16_t __tcpm_pad1; /* zero */
4254 + uint16_t tcpm_keylen; /* key length */
4255 + uint32_t __tcpm_pad2; /* zero */
4256 + uint8_t tcpm_key[TCP_MD5SIG_MAXKEYLEN]; /* key (binary) */
4260 diff -urN -x .git dietlibc-0.33/include/netpacket/packet.h dietlibc/include/netpacket/packet.h
4261 --- dietlibc-0.33/include/netpacket/packet.h 2003-08-19 16:58:18.000000000 +0000
4262 +++ dietlibc/include/netpacket/packet.h 2015-01-01 12:14:43.474938895 +0000
4267 +struct sockaddr_pkt {
4268 + unsigned short int spkt_family;
4269 + unsigned char spkt_device[14];
4270 + unsigned short int spkt_protocol;
4274 struct sockaddr_ll {
4275 unsigned short int sll_family;
4276 unsigned short int sll_protocol;
4278 #define PACKET_OTHERHOST 3 /* To someone else. */
4279 #define PACKET_OUTGOING 4 /* Originated by us. */
4280 #define PACKET_LOOPBACK 5
4281 +#define PACKET_USER 6 /* To user space */
4282 +#define PACKET_KERNEL 7 /* To kernel space */
4283 +/* Unused, PACKET_FASTROUTE and PACKET_LOOPBACK are invisible to user space */
4284 #define PACKET_FASTROUTE 6
4286 /* Packet socket options. */
4288 #define PACKET_RECV_OUTPUT 3
4289 #define PACKET_RX_RING 5
4290 #define PACKET_STATISTICS 6
4291 +#define PACKET_COPY_THRESH 7
4292 +#define PACKET_AUXDATA 8
4293 +#define PACKET_ORIGDEV 9
4294 +#define PACKET_VERSION 10
4295 +#define PACKET_HDRLEN 11
4296 +#define PACKET_RESERVE 12
4297 +#define PACKET_TX_RING 13
4298 +#define PACKET_LOSS 14
4299 +#define PACKET_VNET_HDR 15
4300 +#define PACKET_TX_TIMESTAMP 16
4301 +#define PACKET_TIMESTAMP 17
4302 +#define PACKET_FANOUT 18
4303 +#define PACKET_TX_HAS_OFF 19
4304 +#define PACKET_QDISC_BYPASS 20
4306 +#define PACKET_FANOUT_HASH 0
4307 +#define PACKET_FANOUT_LB 1
4308 +#define PACKET_FANOUT_CPU 2
4309 +#define PACKET_FANOUT_ROLLOVER 3
4310 +#define PACKET_FANOUT_RND 4
4311 +#define PACKET_FANOUT_QM 5
4312 +#define PACKET_FANOUT_FLAG_ROLLOVER 0x1000
4313 +#define PACKET_FANOUT_FLAG_DEFRAG 0x8000
4315 +struct tpacket_stats {
4316 + unsigned int tp_packets;
4317 + unsigned int tp_drops;
4320 +struct tpacket_stats_v3 {
4321 + unsigned int tp_packets;
4322 + unsigned int tp_drops;
4323 + unsigned int tp_freeze_q_cnt;
4326 +union tpacket_stats_u {
4327 + struct tpacket_stats stats1;
4328 + struct tpacket_stats_v3 stats3;
4331 +struct tpacket_auxdata {
4332 + uint32_t tp_status;
4334 + uint32_t tp_snaplen;
4337 + uint16_t tp_vlan_tci;
4338 + uint16_t tp_vlan_tpid;
4341 +/* Rx ring - header status */
4342 +#define TP_STATUS_KERNEL 0
4343 +#define TP_STATUS_USER (1 << 0)
4344 +#define TP_STATUS_COPY (1 << 1)
4345 +#define TP_STATUS_LOSING (1 << 2)
4346 +#define TP_STATUS_CSUMNOTREADY (1 << 3)
4347 +#define TP_STATUS_VLAN_VALID (1 << 4) /* auxdata has valid tp_vlan_tci */
4348 +#define TP_STATUS_BLK_TMO (1 << 5)
4349 +#define TP_STATUS_VLAN_TPID_VALID (1 << 6) /* auxdata has valid tp_vlan_tpid */
4351 +/* Tx ring - header status */
4352 +#define TP_STATUS_AVAILABLE 0
4353 +#define TP_STATUS_SEND_REQUEST (1 << 0)
4354 +#define TP_STATUS_SENDING (1 << 1)
4355 +#define TP_STATUS_WRONG_FORMAT (1 << 2)
4357 +/* Rx and Tx ring - header status */
4358 +#define TP_STATUS_TS_SOFTWARE (1 << 29)
4359 +#define TP_STATUS_TS_SYS_HARDWARE (1 << 30)
4360 +#define TP_STATUS_TS_RAW_HARDWARE (1 << 31)
4362 +/* Rx ring - feature request bits */
4363 +#define TP_FT_REQ_FILL_RXHASH 0x1
4365 +struct tpacket_hdr {
4366 + unsigned long tp_status;
4367 + unsigned int tp_len;
4368 + unsigned int tp_snaplen;
4369 + unsigned short tp_mac;
4370 + unsigned short tp_net;
4371 + unsigned int tp_sec;
4372 + unsigned int tp_usec;
4375 +#define TPACKET_ALIGNMENT 16
4376 +#define TPACKET_ALIGN(x) (((x)+TPACKET_ALIGNMENT-1)&~(TPACKET_ALIGNMENT-1))
4377 +#define TPACKET_HDRLEN (TPACKET_ALIGN(sizeof(struct tpacket_hdr)) + sizeof(struct sockaddr_ll))
4379 +struct tpacket2_hdr {
4380 + uint32_t tp_status;
4382 + uint32_t tp_snaplen;
4387 + uint16_t tp_vlan_tci;
4388 + uint16_t tp_vlan_tpid;
4389 + uint8_t tp_padding[4];
4392 +struct tpacket_hdr_variant1 {
4393 + uint32_t tp_rxhash;
4394 + uint32_t tp_vlan_tci;
4395 + uint16_t tp_vlan_tpid;
4396 + uint16_t tp_padding;
4399 +struct tpacket3_hdr {
4400 + uint32_t tp_next_offset;
4403 + uint32_t tp_snaplen;
4405 + uint32_t tp_status;
4408 + /* pkt_hdr variants */
4410 + struct tpacket_hdr_variant1 hv1;
4412 + uint8_t tp_padding[8];
4415 +struct tpacket_bd_ts {
4416 + unsigned int ts_sec;
4418 + unsigned int ts_usec;
4419 + unsigned int ts_nsec;
4423 +struct tpacket_hdr_v1 {
4424 + uint32_t block_status;
4425 + uint32_t num_pkts;
4426 + uint32_t offset_to_first_pkt;
4428 + /* Number of valid bytes (including padding)
4429 + * blk_len <= tp_block_size
4434 + * Quite a few uses of sequence number:
4435 + * 1. Make sure cache flush etc worked.
4436 + * Well, one can argue - why not use the increasing ts below?
4437 + * But look at 2. below first.
4438 + * 2. When you pass around blocks to other user space decoders,
4439 + * you can see which blk[s] is[are] outstanding etc.
4440 + * 3. Validate kernel code.
4447 + * Case 1. Block has 'N'(N >=1) packets and TMO'd(timed out)
4448 + * ts_last_pkt == 'time-stamp of last packet' and NOT the
4449 + * time when the timer fired and the block was closed.
4450 + * By providing the ts of the last packet we can absolutely
4451 + * guarantee that time-stamp wise, the first packet in the
4452 + * next block will never precede the last packet of the
4454 + * Case 2. Block has zero packets and TMO'd
4455 + * ts_last_pkt = time when the timer fired and the block
4457 + * Case 3. Block has 'N' packets and NO TMO.
4458 + * ts_last_pkt = time-stamp of the last pkt in the block.
4461 + * Is always the time-stamp when the block was opened.
4462 + * Case a) ZERO packets
4463 + * No packets to deal with but atleast you know the
4464 + * time-interval of this block.
4465 + * Case b) Non-zero packets
4466 + * Use the ts of the first packet in the block.
4469 + struct tpacket_bd_ts ts_first_pkt, ts_last_pkt;
4472 +union tpacket_bd_header_u {
4473 + struct tpacket_hdr_v1 bh1;
4476 +struct tpacket_block_desc {
4478 + uint32_t offset_to_priv;
4479 + union tpacket_bd_header_u hdr;
4482 +#define TPACKET2_HDRLEN (TPACKET_ALIGN(sizeof(struct tpacket2_hdr)) + sizeof(struct sockaddr_ll))
4483 +#define TPACKET3_HDRLEN (TPACKET_ALIGN(sizeof(struct tpacket3_hdr)) + sizeof(struct sockaddr_ll))
4485 +enum tpacket_versions {
4494 + - Start. Frame must be aligned to TPACKET_ALIGNMENT=16
4495 + - struct tpacket_hdr
4496 + - pad to TPACKET_ALIGNMENT=16
4497 + - struct sockaddr_ll
4498 + - Gap, chosen so that packet data (Start+tp_net) alignes to TPACKET_ALIGNMENT=16
4499 + - Start+tp_mac: [ Optional MAC header ]
4500 + - Start+tp_net: Packet data, aligned to TPACKET_ALIGNMENT=16.
4501 + - Pad to align to TPACKET_ALIGNMENT=16
4504 +struct tpacket_req {
4505 + unsigned int tp_block_size; /* Minimal size of contiguous block */
4506 + unsigned int tp_block_nr; /* Number of blocks */
4507 + unsigned int tp_frame_size; /* Size of frame */
4508 + unsigned int tp_frame_nr; /* Total number of frames */
4511 +struct tpacket_req3 {
4512 + unsigned int tp_block_size; /* Minimal size of contiguous block */
4513 + unsigned int tp_block_nr; /* Number of blocks */
4514 + unsigned int tp_frame_size; /* Size of frame */
4515 + unsigned int tp_frame_nr; /* Total number of frames */
4516 + unsigned int tp_retire_blk_tov; /* timeout in msecs */
4517 + unsigned int tp_sizeof_priv; /* offset to private data area */
4518 + unsigned int tp_feature_req_word;
4521 +union tpacket_req_u {
4522 + struct tpacket_req req;
4523 + struct tpacket_req3 req3;
4526 struct packet_mreq {
4529 #define PACKET_MR_MULTICAST 0
4530 #define PACKET_MR_PROMISC 1
4531 #define PACKET_MR_ALLMULTI 2
4532 +#define PACKET_MR_UNICAST 3
4536 diff -urN -x .git dietlibc-0.33/include/paths.h dietlibc/include/paths.h
4537 --- dietlibc-0.33/include/paths.h 2008-05-06 17:18:34.000000000 +0000
4538 +++ dietlibc/include/paths.h 2015-01-01 12:14:43.474938895 +0000
4542 #define _PATH_BSHELL "/bin/sh"
4543 -#define _PATH_DEFPATH "/bin:/usr/bin:"
4544 +#define _PATH_DEFPATH "/bin:/usr/bin"
4546 #define _PATH_DEVNULL "/dev/null"
4548 diff -urN -x .git dietlibc-0.33/include/sched.h dietlibc/include/sched.h
4549 --- dietlibc-0.33/include/sched.h 2012-01-24 18:24:25.000000000 +0000
4550 +++ dietlibc/include/sched.h 2015-01-01 12:14:43.478272229 +0000
4553 /* END OF COPY form kernel-header */
4555 -int __sched_setparam(pid_t pid, const struct sched_param* p);
4556 -int sched_setparam(pid_t pid, const struct sched_param* p);
4557 +int __sched_setparam(pid_t pid, const struct sched_param* p) __THROW;
4558 +int sched_setparam(pid_t pid, const struct sched_param* p) __THROW;
4560 -int __sched_getparam(pid_t pid, struct sched_param* p);
4561 -int sched_getparam(pid_t pid, struct sched_param* p);
4562 +int __sched_getparam(pid_t pid, struct sched_param* p) __THROW;
4563 +int sched_getparam(pid_t pid, struct sched_param* p) __THROW;
4565 -int __sched_getscheduler(pid_t pid);
4566 -int sched_getscheduler(pid_t pid);
4567 +int __sched_getscheduler(pid_t pid) __THROW;
4568 +int sched_getscheduler(pid_t pid) __THROW;
4570 -int __sched_setscheduler(pid_t pid, int policy, const struct sched_param* p);
4571 -int sched_setscheduler(pid_t pid, int policy, const struct sched_param* p);
4572 +int __sched_setscheduler(pid_t pid, int policy, const struct sched_param* p) __THROW;
4573 +int sched_setscheduler(pid_t pid, int policy, const struct sched_param* p) __THROW;
4575 -int __sched_yield(void);
4576 -int sched_yield(void);
4577 +int __sched_yield(void) __THROW;
4578 +int sched_yield(void) __THROW;
4580 -int __sched_get_priority_max(int policy);
4581 -int sched_get_priority_max(int policy);
4582 +int __sched_get_priority_max(int policy) __THROW;
4583 +int sched_get_priority_max(int policy) __THROW;
4585 -int __sched_get_priority_min(int policy);
4586 -int sched_get_priority_min(int policy);
4587 +int __sched_get_priority_min(int policy) __THROW;
4588 +int sched_get_priority_min(int policy) __THROW;
4590 -int __sched_rr_get_interval(pid_t pid, struct timespec* tp);
4591 -int sched_rr_get_interval(pid_t pid, struct timespec* tp);
4592 +int __sched_rr_get_interval(pid_t pid, struct timespec* tp) __THROW;
4593 +int sched_rr_get_interval(pid_t pid, struct timespec* tp) __THROW;
4598 #define CLONE_VFORK 0x00004000 /* set if the parent wants the child to wake it up on mm_release */
4599 #define CLONE_PARENT 0x00008000 /* set if we want to have the same parent as the cloner */
4600 #define CLONE_THREAD 0x00010000 /* Same thread group? */
4601 +#define CLONE_NEWNS 0x00020000
4602 +#define CLONE_SYSVSEM 0x00040000
4603 +#define CLONE_SETTLS 0x00080000
4604 +#define CLONE_PARENT_SETTID 0x00100000
4605 +#define CLONE_CHILD_CLEARTID 0x00200000
4606 +#define CLONE_DETACHED 0x00400000
4607 +#define CLONE_UNTRACED 0x00800000
4608 +#define CLONE_CHILD_SETTID 0x01000000
4609 +#define CLONE_NEWUTS 0x04000000
4610 +#define CLONE_NEWIPC 0x08000000
4611 +#define CLONE_NEWUSER 0x10000000
4612 +#define CLONE_NEWPID 0x20000000
4613 +#define CLONE_NEWNET 0x40000000
4614 +#define CLONE_IO 0x80000000
4616 #define CLONE_SIGNAL (CLONE_SIGHAND | CLONE_THREAD)
4618 -int clone(int *(*fn)(void*),void* stack,int flags,void* arg, ...);
4619 +int clone(int (*fn)(void*),void* stack,int flags,void* arg, ...) __THROW;
4621 -int unshare(int flags);
4622 +int unshare(int flags) __THROW;
4624 +long set_tid_address(int* tid) __THROW;
4627 * Linux CPU affinity.
4628 @@ -112,11 +128,13 @@
4632 -int sched_setaffinity(pid_t pid, size_t size, cpu_set_t *mask);
4633 -int sched_getaffinity(pid_t pid, size_t size, cpu_set_t *mask);
4634 +int sched_setaffinity(pid_t pid, size_t size, cpu_set_t *mask) __THROW;
4635 +int sched_getaffinity(pid_t pid, size_t size, cpu_set_t *mask) __THROW;
4636 #define pthread_setaffinity_np sched_setaffinity
4637 #define pthread_getaffinity_np sched_getaffinity
4639 +int setns(int fd,int nstype) __THROW;
4644 diff -urN -x .git dietlibc-0.33/include/search.h dietlibc/include/search.h
4645 --- dietlibc-0.33/include/search.h 1970-01-01 00:00:00.000000000 +0000
4646 +++ dietlibc/include/search.h 2015-01-01 12:14:43.478272229 +0000
4651 +#include <sys/cdefs.h>
4652 +#include <stddef.h>
4653 +#include <stdint.h>
4655 +typedef enum { FIND, ENTER } ACTION;
4656 +typedef struct entry { char* key; void* data; } ENTRY;
4658 +extern ENTRY* hsearch(ENTRY item, ACTION action) __THROW;
4659 +extern int hcreate(size_t count) __THROW;
4660 +extern void hdestroy(void) __THROW;
4663 +/* This is the internal structure of the hash table buckets.
4664 + * Do not use it or your program will be dietlibc-only!
4665 + * It's here so it's possible to write traversal code. */
4667 + struct bucket* next;
4675 +struct hsearch_data {
4676 + struct bucket** table;
4677 + size_t size, filled;
4678 + unsigned char key[16];
4681 +extern int hsearch_r(ENTRY item, ACTION action, ENTRY** retval, struct hsearch_data* htab) __THROW;
4682 +extern int hcreate_r(size_t count, struct hsearch_data* htab) __THROW;
4683 +extern void hdestroy_r(struct hsearch_data* htab) __THROW;
4685 +extern uint64_t siphash24(const unsigned char key[16], const unsigned char *in, size_t len) __THROW;
4688 diff -urN -x .git dietlibc-0.33/include/setjmp.h dietlibc/include/setjmp.h
4689 --- dietlibc-0.33/include/setjmp.h 2005-09-28 06:18:43.000000000 +0000
4690 +++ dietlibc/include/setjmp.h 2015-01-01 12:14:43.478272229 +0000
4693 #define __JMP_BUF_SP 8
4694 #ifndef __ASSEMBLER__
4695 -typedef int __jmp_buf[24];
4696 +typedef int __jmp_buf[10 + 16*2 + 16*2];
4700 @@ -222,12 +222,12 @@
4701 extern int __sigsetjmp(jmp_buf __env,int __savemask) __THROW;
4703 extern void longjmp(jmp_buf __env,int __val)
4704 - __THROW __attribute__((__noreturn__));
4705 + __THROWNL __attribute__((__noreturn__));
4707 typedef jmp_buf sigjmp_buf;
4709 extern void siglongjmp(sigjmp_buf __env,int __val)
4710 - __THROW __attribute__((__noreturn__));
4711 + __THROWNL __attribute__((__noreturn__));
4714 #define setjmp(env) __sigsetjmp(env,1)
4715 diff -urN -x .git dietlibc-0.33/include/signal.h dietlibc/include/signal.h
4716 --- dietlibc-0.33/include/signal.h 2005-09-28 06:18:43.000000000 +0000
4717 +++ dietlibc/include/signal.h 2015-01-01 12:14:43.478272229 +0000
4718 @@ -431,10 +431,10 @@
4719 # define POLL_HUP POLL_HUP
4722 -#define _NSIG_WORDS ((_NSIG/sizeof(long))>>3)
4723 +#define _SIGSET_WORDS (1024 / (8 * sizeof (unsigned long int)))
4726 - unsigned long sig[_NSIG_WORDS];
4727 + unsigned long sig[_SIGSET_WORDS];
4731 diff -urN -x .git dietlibc-0.33/include/stdlib.h dietlibc/include/stdlib.h
4732 --- dietlibc-0.33/include/stdlib.h 2012-01-24 18:24:25.000000000 +0000
4733 +++ dietlibc/include/stdlib.h 2015-01-01 12:14:43.478272229 +0000
4735 void free(void *ptr) __THROW;
4736 void *realloc(void *ptr, size_t size) __THROW __attribute_malloc__;
4738 +/* useful OpenBSD extension: */
4739 +void* reallocarray(void* ptr, size_t nmemb, size_t size) __THROW __attribute_malloc__;
4741 char *getenv(const char *name) __THROW __pure;
4742 int putenv(const char *string) __THROW;
4743 int setenv(const char *name, const char *value, int overwrite) __THROW;
4745 long int strtol(const char *nptr, char **endptr, int base) __THROW;
4746 unsigned long int strtoul(const char *nptr, char **endptr, int base) __THROW;
4748 +/* HACK: used flags in __dtostr
4750 + 0x02 ... uppercase
4751 + Define some constants somewhere... */
4752 extern int __ltostr(char *s, unsigned int size, unsigned long i, unsigned int base, int UpCase) __THROW;
4753 -extern int __dtostr(double d,char *buf,unsigned int maxlen,unsigned int prec,unsigned int prec2,int g) __THROW;
4754 +extern int __dtostr(double d,char *buf,unsigned int maxlen,unsigned int prec,unsigned int prec2,int flags) __THROW;
4756 #if !defined(__STRICT_ANSI__) || __STDC_VERSION__ + 0 >= 199900L
4757 __extension__ long long int strtoll(const char *nptr, char **endptr, int base) __THROW;
4759 __extension__ long long int atoll(const char *nptr);
4761 void exit(int status) __THROW __attribute__((__noreturn__));
4762 -void abort(void) __THROW;
4763 +void abort(void) __THROW __attribute__((__noreturn__));
4765 extern int rand(void) __THROW;
4766 extern int rand_r(unsigned int *seed) __THROW;
4767 diff -urN -x .git dietlibc-0.33/include/sys/atomic.h dietlibc/include/sys/atomic.h
4768 --- dietlibc-0.33/include/sys/atomic.h 2012-04-19 16:50:20.000000000 +0000
4769 +++ dietlibc/include/sys/atomic.h 2015-01-01 12:14:43.478272229 +0000
4772 #define __kernel_cmpxchg (*(__kernel_cmpxchg_t *)0xffff0fc0)
4774 -#define CAS(ptr,oldval,newval) __kernel_cmpxchg(oldval,newval,ptr)
4775 +#define __CAS(ptr,oldval,newval) __kernel_cmpxchg(oldval,newval,ptr)
4779 -#if defined(__INTEL_COMPILER) || (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 1))
4780 +#elif defined(__INTEL_COMPILER) || (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 1))
4782 /* recent gcc versions and the intel compiler have built-ins for this */
4783 #define __CAS(ptr,oldval,newval) __sync_val_compare_and_swap(ptr,oldval,newval)
4791 #if defined(__INTEL_COMPILER) || (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 1))
4793 diff -urN -x .git dietlibc-0.33/include/sys/auxv.h dietlibc/include/sys/auxv.h
4794 --- dietlibc-0.33/include/sys/auxv.h 1970-01-01 00:00:00.000000000 +0000
4795 +++ dietlibc/include/sys/auxv.h 2015-01-01 12:14:43.478272229 +0000
4800 +#include <sys/cdefs.h>
4802 +unsigned long getauxval(unsigned long type);
4805 +/* don't fail if they already included elf.h */
4808 + AT_BASE_PLATFORM=24,
4810 + AT_DCACHEBSIZE=19,
4821 + AT_ICACHEBSIZE=20,
4830 + AT_SYSINFO_EHDR=33,
4831 + AT_UCACHEBSIZE=21,
4837 diff -urN -x .git dietlibc-0.33/include/sys/cdefs.h dietlibc/include/sys/cdefs.h
4838 --- dietlibc-0.33/include/sys/cdefs.h 2009-07-01 00:27:26.000000000 +0000
4839 +++ dietlibc/include/sys/cdefs.h 2015-01-01 12:14:43.478272229 +0000
4841 #define __extension__
4844 +#if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 6))
4845 +#define __leaf , __leaf__
4850 +#if !defined(__cplusplus) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)))
4852 +#define __THROW __attribute__((__nothrow__ __leaf))
4853 +#define __THROWNL __attribute__((__nothrow__))
4857 +#define __THROWNL __THROW
4860 #if (__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 96))
4861 #define __pure __attribute__ ((__pure__))
4863 diff -urN -x .git dietlibc-0.33/include/sys/epoll.h dietlibc/include/sys/epoll.h
4864 --- dietlibc-0.33/include/sys/epoll.h 2012-11-02 11:17:28.000000000 +0000
4865 +++ dietlibc/include/sys/epoll.h 2015-01-01 12:14:43.478272229 +0000
4867 #include <sys/types.h>
4874 -/* Flags for epoll_create1. */
4875 -#define EPOLL_CLOEXEC O_CLOEXEC
4877 /* Valid opcodes ( "op" parameter ) to issue to epoll_ctl() */
4878 #define EPOLL_CTL_ADD 1 /* Add a file decriptor to the interface */
4879 #define EPOLL_CTL_DEL 2 /* Remove a file decriptor from the interface */
4881 #define EPOLLET EPOLLET
4884 +/* flags for epoll_create1 */
4886 + EPOLL_CLOEXEC = O_CLOEXEC
4887 +#define EPOLL_CLOEXEC EPOLL_CLOEXEC
4891 typedef union epoll_data {
4897 int epoll_create(int size) __THROW;
4898 +int epoll_create1(int flags) __THROW;
4899 int epoll_ctl(int epfd, int op, int fd, struct epoll_event* event) __THROW;
4900 int epoll_wait(int epfd, struct epoll_event *events, int maxevents,
4901 int timeout) __THROW;
4902 diff -urN -x .git dietlibc-0.33/include/sys/eventfd.h dietlibc/include/sys/eventfd.h
4903 --- dietlibc-0.33/include/sys/eventfd.h 1970-01-01 00:00:00.000000000 +0000
4904 +++ dietlibc/include/sys/eventfd.h 2015-01-01 12:14:43.478272229 +0000
4906 +#ifndef _SYS_EVENTFD_H
4907 +#define _SYS_EVENTFD_H
4909 +#include <sys/cdefs.h>
4910 +#include <sys/types.h>
4916 + EFD_CLOEXEC = O_CLOEXEC,
4917 +#define EFD_CLOEXEC EFD_CLOEXEC
4918 + EFD_NONBLOCK = O_NONBLOCK,
4919 +#define EFD_NONBLOCK EFD_NONBLOCK
4921 +#define EFD_SEMAPHORE EFD_SEMAPHORE
4924 +typedef uint64_t eventfd_t;
4926 +int eventfd(unsigned int initval, int flags) __THROW;
4931 diff -urN -x .git dietlibc-0.33/include/sys/fanotify.h dietlibc/include/sys/fanotify.h
4932 --- dietlibc-0.33/include/sys/fanotify.h 1970-01-01 00:00:00.000000000 +0000
4933 +++ dietlibc/include/sys/fanotify.h 2015-01-01 12:14:43.478272229 +0000
4935 +#ifndef SYS_FANOITFY_H
4936 +#define SYS_FANOITFY_H
4938 +#include <sys/cdefs.h>
4939 +#include <stdint.h>
4940 +#include <sys/types.h>
4942 +struct fanotify_event_metadata {
4943 + uint32_t event_len;
4944 + uint8_t vers, reserved;
4945 + uint16_t metadata_len;
4952 +int fanotify_init(unsigned int flags, unsigned int event_f_flags);
4953 +int fanotify_mark(int fanotify_fd, unsigned int flags,
4954 + uint64_t mask, int dirfd, const char *pathname);
4959 diff -urN -x .git dietlibc-0.33/include/sys/futex.h dietlibc/include/sys/futex.h
4960 --- dietlibc-0.33/include/sys/futex.h 2005-10-04 17:47:03.000000000 +0000
4961 +++ dietlibc/include/sys/futex.h 2015-01-01 12:14:43.478272229 +0000
4963 #ifndef _SYS_FUTEX_H
4964 #define _SYS_FUTEX_H
4966 +#include <sys/types.h>
4967 #include <sys/time.h>
4976 long futex(int* uaddr,int op,int val,const struct timespec* timeout,int* uaddr2,int val3);
4981 diff -urN -x .git dietlibc-0.33/include/sys/inotify.h dietlibc/include/sys/inotify.h
4982 --- dietlibc-0.33/include/sys/inotify.h 2008-05-06 17:18:34.000000000 +0000
4983 +++ dietlibc/include/sys/inotify.h 2015-01-01 12:14:43.478272229 +0000
4985 IN_MOVED_TO | IN_DELETE | IN_CREATE | IN_DELETE_SELF | \
4988 +/* Flags for sys_inotify_init1. */
4989 +#define IN_CLOEXEC O_CLOEXEC
4990 +#define IN_NONBLOCK O_NONBLOCK
4994 int inotify_init(void) __THROW;
4995 -int inotify_add_watch(int fd,const char* path,unsigned long mask);
4996 -int inotify_rm_watch(int fd,int wd);
4997 +int inotify_init1(int flags) __THROW;
4998 +int inotify_add_watch(int fd,const char* path,unsigned long mask) __THROW;
4999 +int inotify_rm_watch(int fd,int wd) __THROW;
5003 diff -urN -x .git dietlibc-0.33/include/sys/mman.h dietlibc/include/sys/mman.h
5004 --- dietlibc-0.33/include/sys/mman.h 2007-10-17 11:47:57.000000000 +0000
5005 +++ dietlibc/include/sys/mman.h 2015-01-01 12:14:43.478272229 +0000
5007 #define PROT_READ 0x1 /* page can be read */
5008 #define PROT_WRITE 0x2 /* page can be written */
5009 #define PROT_EXEC 0x4 /* page can be executed */
5010 +#define PROT_SEM 0x8 /* page may be used for atomic ops */
5011 #define PROT_NONE 0x0 /* page can not be accessed */
5013 +#define PROT_GROWSDOWN 0x01000000 /* mprotect flag: extend change to start of growsdown vma */
5014 +#define PROT_GROWSUP 0x02000000 /* mprotect flag: extend change to end of growsdown vma */
5016 #define MAP_SHARED 0x01 /* Share changes */
5017 #define MAP_PRIVATE 0x02 /* Changes are private */
5018 +#define MAP_TYPE 0xf /* Mask for type of mapping */
5020 +#define MADV_REMOVE 9
5021 +#define MADV_DONTFORK 10
5022 +#define MADV_DOFORK 11
5023 +#define MADV_MERGEABLE 12
5024 +#define MADV_UNMERGEABLE 13
5025 +#define MADV_HUGEPAGE 14
5026 +#define MADV_NOHUGEPAGE 15
5027 +#define MADV_DONTDUMP 16
5028 +#define MADV_DODUMP 17
5029 +#define MADV_HWPOISON 100
5030 +#define MADV_SOFT_OFFLINE 101
5032 #if defined(__mips__)
5033 #define MAP_FIXED 0x010 /* Interpret addr exactly */
5035 #define MAP_EXECUTABLE 0x4000 /* mark it as an executable */
5036 #define MAP_LOCKED 0x8000 /* pages are locked */
5037 #define MAP_POPULATE 0x10000
5038 +#define MAP_NONBLOCK 0x20000
5039 +#define MAP_STACK 0x40000
5040 +#define MAP_HUGETLB 0x80000
5041 #define MS_ASYNC 0x0001 /* sync memory asynchronously */
5042 #define MS_INVALIDATE 0x0002 /* invalidate mappings & caches */
5043 #define MS_SYNC 0x0004 /* synchronous memory sync */
5045 #define MAP_LOCKED 0x8000 /* lock the mapping */
5046 #define MAP_NORESERVE 0x10000 /* don't check for reservations */
5047 #define MAP_POPULATE 0x20000
5048 +#define MAP_NONBLOCK 0x40000
5049 +#define MAP_STACK 0x80000
5050 +#define MAP_HUGETLB 0x100000
5051 #define MS_ASYNC 1 /* sync memory asynchronously */
5052 #define MS_SYNC 2 /* synchronous memory sync */
5053 #define MS_INVALIDATE 4 /* invalidate the caches */
5055 #define MADV_WILLNEED 3 /* will need these pages */
5056 #define MADV_SPACEAVAIL 5 /* ensure resources are available */
5057 #define MADV_DONTNEED 6 /* dont need these pages */
5058 -#elif defined(__i386__) || defined(__s390__) || defined(__x86_64__)
5060 +#elif defined(__i386__) || defined(__s390__) || defined(__x86_64__) || defined(__arm__)
5061 #define MAP_FIXED 0x10 /* Interpret addr exactly */
5062 #define MAP_ANONYMOUS 0x20 /* don't use a file */
5063 #define MAP_GROWSDOWN 0x0100 /* stack-like segment */
5065 #define MAP_LOCKED 0x2000 /* pages are locked */
5066 #define MAP_NORESERVE 0x4000 /* don't check for reservations */
5067 #define MAP_POPULATE 0x8000
5068 +#define MAP_NONBLOCK 0x10000
5069 +#define MAP_STACK 0x20000
5070 +#define MAP_HUGETLB 0x40000
5071 #define MS_ASYNC 1 /* sync memory asynchronously */
5072 #define MS_INVALIDATE 2 /* invalidate the caches */
5073 #define MS_SYNC 4 /* synchronous memory sync */
5075 #define MADV_SEQUENTIAL 0x2 /* read-ahead aggressively */
5076 #define MADV_WILLNEED 0x3 /* pre-fault pages */
5077 #define MADV_DONTNEED 0x4 /* discard these pages */
5079 #elif defined(__sparc__) || defined (__powerpc__) || defined (__powerpc64__)
5080 #define MAP_FIXED 0x10 /* Interpret addr exactly */
5081 #define MAP_ANONYMOUS 0x20 /* don't use a file */
5083 #define MAP_DENYWRITE 0x0800 /* ETXTBSY */
5084 #define MAP_EXECUTABLE 0x1000 /* mark it as an executable */
5085 #define MAP_POPULATE 0x8000
5086 +#define MAP_NONBLOCK 0x10000
5087 +#define MAP_STACK 0x20000
5088 +#define MAP_HUGETLB 0x40000
5089 #define MS_ASYNC 1 /* sync memory asynchronously */
5090 #define MS_INVALIDATE 2 /* invalidate the caches */
5091 #define MS_SYNC 4 /* synchronous memory sync */
5093 #define MADV_WILLNEED 0x3 /* pre-fault pages */
5094 #define MADV_DONTNEED 0x4 /* discard these pages */
5095 #define MADV_FREE 0x5 /* (Solaris) contents can be freed */
5096 -#elif defined (__arm__)
5097 -#define MAP_FIXED 0x10 /* Interpret addr exactly */
5098 -#define MAP_ANONYMOUS 0x20 /* don't use a file */
5099 -#define MAP_GROWSDOWN 0x0100 /* stack-like segment */
5100 -#define MAP_DENYWRITE 0x0800 /* ETXTBSY */
5101 -#define MAP_EXECUTABLE 0x1000 /* mark it as an executable */
5102 -#define MAP_LOCKED 0x2000 /* pages are locked */
5103 -#define MAP_NORESERVE 0x4000 /* don't check for reservations */
5104 -#define MAP_POPULATE 0x8000
5105 -#define MS_ASYNC 1 /* sync memory asynchronously */
5106 -#define MS_INVALIDATE 2 /* invalidate the caches */
5107 -#define MS_SYNC 4 /* synchronous memory sync */
5108 -#define MCL_CURRENT 1 /* lock all current mappings */
5109 -#define MCL_FUTURE 2 /* lock all future mappings */
5110 -#define MADV_NORMAL 0x0 /* default page-in behavior */
5111 -#define MADV_RANDOM 0x1 /* page-in minimum required */
5112 -#define MADV_SEQUENTIAL 0x2 /* read-ahead aggressively */
5113 -#define MADV_WILLNEED 0x3 /* pre-fault pages */
5114 -#define MADV_DONTNEED 0x4 /* discard these pages */
5116 #elif defined(__hppa__)
5118 #define MAP_TYPE 0x03 /* Mask for type of mapping */
5119 #define MAP_FIXED 0x04 /* Interpret addr exactly */
5120 #define MAP_ANONYMOUS 0x10 /* don't use a file */
5122 #define MAP_NORESERVE 0x4000 /* don't check for reservations */
5123 #define MAP_GROWSDOWN 0x8000 /* stack-like segment */
5124 #define MAP_POPULATE 0x10000
5125 +#define MAP_NONBLOCK 0x20000
5126 +#define MAP_STACK 0x40000
5127 +#define MAP_HUGETLB 0x80000
5129 #define MS_SYNC 1 /* synchronous memory sync */
5130 #define MS_ASYNC 2 /* sync memory asynchronously */
5131 @@ -154,9 +170,23 @@
5132 #define MADV_4M_PAGES 22 /* Use 4 Megabyte pages */
5133 #define MADV_16M_PAGES 24 /* Use 16 Megabyte pages */
5134 #define MADV_64M_PAGES 26 /* Use 64 Megabyte pages */
5136 +#undef MADV_MERGEABLE
5137 +#undef MADV_UNMERGEABLE
5138 +#undef MADV_HUGEPAGE
5139 +#undef MADV_NOHUGEPAGE
5140 +#undef MADV_DONTDUMP
5143 +#define MADV_MERGEABLE 65
5144 +#define MADV_UNMERGEABLE 66
5145 +#define MADV_HUGEPAGE 67
5146 +#define MADV_NOHUGEPAGE 68
5147 +#define MADV_DONTDUMP 69
5148 +#define MADV_DODUMP 70
5150 #elif defined(__ia64__)
5152 -#define MAP_TYPE 0x0f /* Mask for type of mapping */
5153 #define MAP_FIXED 0x10 /* Interpret addr exactly */
5154 #define MAP_ANONYMOUS 0x20 /* don't use a file */
5157 #define MAP_LOCKED 0x2000 /* pages are locked */
5158 #define MAP_NORESERVE 0x4000 /* don't check for reservations */
5159 #define MAP_POPULATE 0x8000
5160 -#define MAP_WRITECOMBINED 0x10000 /* write-combine the area */
5161 -#define MAP_NONCACHED 0x20000 /* don't cache the memory */
5162 +#define MAP_NONBLOCK 0x10000
5163 +#define MAP_STACK 0x20000
5164 +#define MAP_HUGETLB 0x40000
5166 #define MS_ASYNC 1 /* sync memory asynchronously */
5167 #define MS_INVALIDATE 2 /* invalidate the caches */
5168 diff -urN -x .git dietlibc-0.33/include/sys/prctl.h dietlibc/include/sys/prctl.h
5169 --- dietlibc-0.33/include/sys/prctl.h 2007-03-09 13:42:12.000000000 +0000
5170 +++ dietlibc/include/sys/prctl.h 2015-01-01 12:14:43.478272229 +0000
5172 #define _SYS_PRCTL_H
5174 #include <sys/cdefs.h>
5176 -/* Values to pass as first argument to prctl() */
5178 -#define PR_SET_PDEATHSIG 1 /* Second arg is a signal */
5179 -#define PR_GET_PDEATHSIG 2 /* Second arg is a ptr to return the signal */
5181 -/* Get/set current->mm->dumpable */
5182 -#define PR_GET_DUMPABLE 3
5183 -#define PR_SET_DUMPABLE 4
5185 -/* Get/set unaligned access control bits (if meaningful) */
5186 -#define PR_GET_UNALIGN 5
5187 -#define PR_SET_UNALIGN 6
5188 -# define PR_UNALIGN_NOPRINT 1 /* silently fix up unaligned user accesses */
5189 -# define PR_UNALIGN_SIGBUS 2 /* generate SIGBUS on unaligned user access */
5191 -/* Get/set whether or not to drop capabilities on setuid() away from uid 0 */
5192 -#define PR_GET_KEEPCAPS 7
5193 -#define PR_SET_KEEPCAPS 8
5195 -/* Get/set floating-point emulation control bits (if meaningful) */
5196 -#define PR_GET_FPEMU 9
5197 -#define PR_SET_FPEMU 10
5198 -# define PR_FPEMU_NOPRINT 1 /* silently emulate fp operations accesses */
5199 -# define PR_FPEMU_SIGFPE 2 /* don't emulate fp operations, send SIGFPE instead */
5201 -/* Get/set floating-point exception mode (if meaningful) */
5202 -#define PR_GET_FPEXC 11
5203 -#define PR_SET_FPEXC 12
5204 -# define PR_FP_EXC_SW_ENABLE 0x80 /* Use FPEXC for FP exception enables */
5205 -# define PR_FP_EXC_DIV 0x010000 /* floating point divide by zero */
5206 -# define PR_FP_EXC_OVF 0x020000 /* floating point overflow */
5207 -# define PR_FP_EXC_UND 0x040000 /* floating point underflow */
5208 -# define PR_FP_EXC_RES 0x080000 /* floating point inexact result */
5209 -# define PR_FP_EXC_INV 0x100000 /* floating point invalid operation */
5210 -# define PR_FP_EXC_DISABLED 0 /* FP exceptions disabled */
5211 -# define PR_FP_EXC_NONRECOV 1 /* async non-recoverable exc. mode */
5212 -# define PR_FP_EXC_ASYNC 2 /* async recoverable exception mode */
5213 -# define PR_FP_EXC_PRECISE 3 /* precise exception mode */
5215 -/* Get/set whether we use statistical process timing or accurate timestamp
5216 - * based process timing */
5217 -#define PR_GET_TIMING 13
5218 -#define PR_SET_TIMING 14
5219 -# define PR_TIMING_STATISTICAL 0 /* Normal, traditional,
5220 - statistical process timing */
5221 -# define PR_TIMING_TIMESTAMP 1 /* Accurate timestamp based
5224 -#define PR_SET_NAME 15 /* Set process name */
5225 -#define PR_GET_NAME 16 /* Get process name */
5227 -/* Get/set process endian */
5228 -#define PR_GET_ENDIAN 19
5229 -#define PR_SET_ENDIAN 20
5230 -# define PR_ENDIAN_BIG 0
5231 -# define PR_ENDIAN_LITTLE 1 /* True little endian mode */
5232 -# define PR_ENDIAN_PPC_LITTLE 2 /* "PowerPC" pseudo little endian */
5234 +#include <linux/prctl.h>
5238 diff -urN -x .git dietlibc-0.33/include/sys/shm.h dietlibc/include/sys/shm.h
5239 --- dietlibc-0.33/include/sys/shm.h 2005-09-28 06:18:43.000000000 +0000
5240 +++ dietlibc/include/sys/shm.h 2015-01-01 12:14:43.478272229 +0000
5242 unsigned long swap_successes;
5245 -#if defined(__i386__) || defined(__mips__) || defined(__arm__) || defined(__powerpc__) || defined (__powerpc64__) || defined(__s390__) || defined(__hppa__) || defined(__x86_64__) || defined(__ia64__)
5246 -#define PAGE_SIZE 4096UL
5247 -#define PAGE_SHIFT 12
5248 -#elif defined(__alpha__) || defined(__sparc__)
5249 -/* sun4* has 4k except sun4 architecture, sparc64 has 8k */
5250 -#define PAGE_SIZE 8192UL
5251 -#define PAGE_SHIFT 13
5254 extern int shmget(key_t key, int size, int shmflg) __THROW;
5255 extern void *shmat(int shmid, const void *shmaddr, int shmflg) __THROW;
5256 extern int shmdt (const void *shmaddr) __THROW;
5257 diff -urN -x .git dietlibc-0.33/include/sys/signalfd.h dietlibc/include/sys/signalfd.h
5258 --- dietlibc-0.33/include/sys/signalfd.h 2008-02-19 00:28:13.000000000 +0000
5259 +++ dietlibc/include/sys/signalfd.h 2015-01-01 12:14:43.478272229 +0000
5263 extern int signalfd (int __fd, const sigset_t *__mask, int __flags)
5264 - __nonnull ((2)) __THROW;
5265 + __THROW __nonnull ((2)) ;
5269 diff -urN -x .git dietlibc-0.33/include/sys/socket.h dietlibc/include/sys/socket.h
5270 --- dietlibc-0.33/include/sys/socket.h 2012-11-02 11:17:28.000000000 +0000
5271 +++ dietlibc/include/sys/socket.h 2015-01-01 12:14:43.478272229 +0000
5274 #include <sys/cdefs.h>
5275 #include <sys/types.h>
5280 /* For setsockopt(2) */
5282 #if defined(__alpha__) || defined(__mips__)
5283 #define SOL_SOCKET 0xffff
5285 #define SO_DEBUG 0x0001
5286 #define SO_REUSEADDR 0x0004
5287 -#define SO_TYPE 0x1008
5288 -#define SO_ERROR 0x1007
5289 +#define SO_KEEPALIVE 0x0008
5290 #define SO_DONTROUTE 0x0010
5291 #define SO_BROADCAST 0x0020
5292 +#define SO_LINGER 0x0080
5293 +#define SO_OOBINLINE 0x0100
5294 +#define SO_REUSEPORT 0x0200
5295 +#define SO_TYPE 0x1008
5296 +#define SO_ERROR 0x1007
5297 #define SO_SNDBUF 0x1001
5298 #define SO_RCVBUF 0x1002
5299 -#define SO_KEEPALIVE 0x0008
5300 -#define SO_OOBINLINE 0x0100
5302 #define SO_NO_CHECK 11
5303 #define SO_PRIORITY 12
5304 -#define SO_LINGER 0x0080
5305 #define SO_BSDCOMPAT 14
5306 -/* To add :#define SO_REUSEPORT 15 */
5307 #define SO_PASSCRED 17
5308 #define SO_PEERCRED 18
5309 -#define SO_RCVLOWAT 0x1004
5310 -#define SO_SNDLOWAT 0x1003
5311 -#define SO_RCVTIMEO 0x1006
5312 -#define SO_SNDTIMEO 0x1005
5313 -#define SO_ACCEPTCONN 0x1009
5315 +/* Security levels - as per NRL IPv6 - don't actually do anything */
5316 +#define SO_SECURITY_AUTHENTICATION 19
5317 +#define SO_SECURITY_ENCRYPTION_TRANSPORT 20
5318 +#define SO_SECURITY_ENCRYPTION_NETWORK 21
5320 +#define SO_BINDTODEVICE 25
5321 +#define SO_ATTACH_FILTER 26
5322 +#define SO_DETACH_FILTER 27
5323 +#define SO_GET_FILTER SO_ATTACH_FILTER
5324 +#define SO_PEERNAME 28
5325 +#define SO_TIMESTAMP 29
5326 +#define SCM_TIMESTAMP SO_TIMESTAMP
5327 +#define SO_PEERSEC 30
5328 +#define SO_PASSSEC 34
5329 +#define SO_TIMESTAMPNS 35
5330 +#define SCM_TIMESTAMPNS SO_TIMESTAMPNS
5332 +#define SO_TIMESTAMPING 37
5333 +#define SCM_TIMESTAMPING SO_TIMESTAMPING
5334 +#define SO_RXQ_OVFL 40
5335 +#define SO_WIFI_STATUS 41
5336 +#define SCM_WIFI_STATUS SO_WIFI_STATUS
5337 +#define SO_PEEK_OFF 42
5339 +/* Instruct lower device to use last 4-bytes of skb data as FCS */
5340 +#define SO_NOFCS 43
5342 +#define SO_LOCK_FILTER 44
5344 +#define SO_SELECT_ERR_QUEUE 45
5346 +#define SO_BUSY_POLL 46
5348 +#define SO_MAX_PACING_RATE 47
5350 +#define SO_BPF_EXTENSIONS 48
5354 #define SO_SNDBUFFORCE 0x100a
5355 #define SO_RCVBUFFORCE 0x100b
5357 +#define SO_RCVLOWAT 0x1010
5358 +#define SO_SNDLOWAT 0x1011
5359 +#define SO_RCVTIMEO 0x1012
5360 +#define SO_SNDTIMEO 0x1013
5361 +#define SO_ACCEPTCONN 0x1014
5365 #define SO_SNDBUFFORCE 31
5366 #define SO_RCVBUFFORCE 33
5368 +#define SO_RCVLOWAT 0x1004
5369 +#define SO_SNDLOWAT 0x1003
5370 +#define SO_RCVTIMEO 0x1006
5371 +#define SO_SNDTIMEO 0x1005
5372 +#define SO_ACCEPTCONN 0x1009
5376 +#define SO_PROTOCOL 0x1028
5377 +#define SO_DOMAIN 0x1029
5379 #define SO_STYLE SO_TYPE /* Synonym */
5381 #elif defined(__hppa__)
5383 #define SO_PEERCRED 0x4011
5384 #define SO_TIMESTAMP 0x4012
5385 #define SCM_TIMESTAMP SO_TIMESTAMP
5386 +#define SO_TIMESTAMPNS 0x4013
5387 +#define SCM_TIMESTAMPNS SO_TIMESTAMPNS
5389 /* Security levels - as per NRL IPv6 - don't actually do anything */
5390 #define SO_SECURITY_AUTHENTICATION 0x4016
5392 /* Socket filtering */
5393 #define SO_ATTACH_FILTER 0x401a
5394 #define SO_DETACH_FILTER 0x401b
5395 +#define SO_GET_FILTER SO_ATTACH_FILTER
5397 #define SO_ACCEPTCONN 0x401c
5399 +#define SO_PEERSEC 0x401d
5400 +#define SO_PASSSEC 0x401e
5402 +#define SO_MARK 0x401f
5404 +#define SO_TIMESTAMPING 0x4020
5405 +#define SCM_TIMESTAMPING SO_TIMESTAMPING
5407 +#define SO_RXQ_OVFL 0x4021
5409 +#define SO_WIFI_STATUS 0x4022
5410 +#define SCM_WIFI_STATUS SO_WIFI_STATUS
5411 +#define SO_PEEK_OFF 0x4023
5413 +/* Instruct lower device to use last 4-bytes of skb data as FCS */
5414 +#define SO_NOFCS 0x4024
5416 +#define SO_LOCK_FILTER 0x4025
5418 +#define SO_SELECT_ERR_QUEUE 0x4026
5420 +#define SO_BUSY_POLL 0x4027
5422 +#define SO_MAX_PACING_RATE 0x4028
5424 +#define SO_BPF_EXTENSIONS 0x4029
5426 #elif defined(__sparc__)
5427 #define SOL_SOCKET 0xffff
5429 @@ -120,11 +204,41 @@
5431 #define SO_ATTACH_FILTER 0x001a
5432 #define SO_DETACH_FILTER 0x001b
5433 +#define SO_GET_FILTER SO_ATTACH_FILTER
5435 #define SO_PEERNAME 0x001c
5436 #define SO_TIMESTAMP 0x001d
5437 #define SCM_TIMESTAMP SO_TIMESTAMP
5439 +#define SO_PEERSEC 0x001e
5440 +#define SO_PASSSEC 0x001f
5441 +#define SO_TIMESTAMPNS 0x0021
5442 +#define SCM_TIMESTAMPNS SO_TIMESTAMPNS
5444 +#define SO_MARK 0x0022
5446 +#define SO_TIMESTAMPING 0x0023
5447 +#define SCM_TIMESTAMPING SO_TIMESTAMPING
5449 +#define SO_RXQ_OVFL 0x0024
5451 +#define SO_WIFI_STATUS 0x0025
5452 +#define SCM_WIFI_STATUS SO_WIFI_STATUS
5453 +#define SO_PEEK_OFF 0x0026
5455 +/* Instruct lower device to use last 4-bytes of skb data as FCS */
5456 +#define SO_NOFCS 0x0027
5458 +#define SO_LOCK_FILTER 0x0028
5460 +#define SO_SELECT_ERR_QUEUE 0x0029
5462 +#define SO_BUSY_POLL 0x0030
5464 +#define SO_MAX_PACING_RATE 0x0031
5466 +#define SO_BPF_EXTENSIONS 0x0032
5468 /* Security levels - as per NRL IPv6 - don't actually do anything */
5469 #define SO_SECURITY_AUTHENTICATION 0x5001
5470 #define SO_SECURITY_ENCRYPTION_TRANSPORT 0x5002
5471 @@ -155,28 +269,63 @@
5472 #define SO_SNDLOWAT 19
5473 #define SO_RCVTIMEO 20
5474 #define SO_SNDTIMEO 21
5475 -#define SO_ACCEPTCONN 30
5476 -#define SO_SNDBUFFORCE 32
5477 -#define SO_RCVBUFFORCE 33
5481 -#if !defined(__hppa__) && !defined(__sparc__)
5482 /* Security levels - as per NRL IPv6 - don't actually do anything */
5483 #define SO_SECURITY_AUTHENTICATION 22
5484 #define SO_SECURITY_ENCRYPTION_TRANSPORT 23
5485 #define SO_SECURITY_ENCRYPTION_NETWORK 24
5487 #define SO_BINDTODEVICE 25
5489 -/* Socket filtering */
5490 -#define SO_ATTACH_FILTER 26
5491 -#define SO_DETACH_FILTER 27
5493 +#define SO_ATTACH_FILTER 26
5494 +#define SO_DETACH_FILTER 27
5495 +#define SO_GET_FILTER SO_ATTACH_FILTER
5496 #define SO_PEERNAME 28
5497 #define SO_TIMESTAMP 29
5498 #define SCM_TIMESTAMP SO_TIMESTAMP
5500 +#define SO_ACCEPTCONN 30
5501 +#define SO_PEERSEC 31
5502 +#define SO_SNDBUFFORCE 32
5503 +#define SO_RCVBUFFORCE 33
5504 +#define SO_PASSSEC 34
5505 +#define SO_TIMESTAMPNS 35
5506 +#define SCM_TIMESTAMPNS SO_TIMESTAMPNS
5510 +#define SO_TIMESTAMPING 37
5511 +#define SCM_TIMESTAMPING SO_TIMESTAMPING
5513 +#define SO_PROTOCOL 38
5514 +#define SO_DOMAIN 39
5516 +#define SO_RXQ_OVFL 40
5518 +#define SO_WIFI_STATUS 41
5519 +#define SCM_WIFI_STATUS SO_WIFI_STATUS
5520 +#define SO_PEEK_OFF 42
5522 +/* Instruct lower device to use last 4-bytes of skb data as FCS */
5523 +#define SO_NOFCS 43
5525 +#define SO_LOCK_FILTER 44
5527 +#define SO_SELECT_ERR_QUEUE 45
5529 +#define SO_BUSY_POLL 46
5531 +#define SO_MAX_PACING_RATE 47
5533 +#define SO_BPF_EXTENSIONS 48
5537 +#if defined(__hppa__) || defined(__alpha__)
5538 +#define SOCK_NONBLOCK 0x40000000
5540 +#define SOCK_NONBLOCK O_NONBLOCK
5542 +#define SOCK_CLOEXEC O_CLOEXEC
5547 #define SOCK_RAW 3 /* raw socket */
5548 #define SOCK_RDM 4 /* reliably-delivered message */
5549 #define SOCK_SEQPACKET 5 /* sequential packet socket */
5550 +#define SOCK_DCCP 6 /* Datagram Congestion Control Protocol socket */
5551 #define SOCK_PACKET 10 /* linux specific way of */
5552 /* getting packets at the dev */
5553 /* level. For writing rarp and */
5554 @@ -324,6 +474,14 @@
5555 #define MSG_ERRQUEUE 0x2000 /* Fetch message from error queue */
5556 #define MSG_NOSIGNAL 0x4000 /* Do not generate SIGPIPE */
5557 #define MSG_MORE 0x8000 /* Sender will send more */
5558 +#define MSG_WAITFORONE 0x10000 /* recvmmsg(): block until 1+ packets avail */
5559 +#define MSG_SENDPAGE_NOTLAST 0x20000 /* sendpage() internal : not the last page */
5560 +#define MSG_EOF MSG_FIN
5562 +#define MSG_FASTOPEN 0x20000000 /* Send data in TCP SYN */
5563 +#define MSG_CMSG_CLOEXEC 0x40000000 /* Set close_on_exit for file
5564 + descriptor received through
5567 /* Setsockoptions(2) level. Thanks to BSD these must match IPPROTO_xxx */
5569 @@ -381,16 +539,6 @@
5570 char __ss_padding[(128 - (2 * sizeof (uint32_t ))) ];
5574 -/* the Linux kernel headers suck really badly on non-x86 */
5575 -#define SOCK_STREAM 1 /* stream (connection) socket */
5576 -#define SOCK_DGRAM 2 /* datagram (conn.less) socket */
5577 -#define SOCK_RAW 3 /* raw socket */
5578 -#define SOCK_RDM 4 /* reliably-delivered message */
5579 -#define SOCK_SEQPACKET 5 /* sequential packet socket */
5580 -#define SOCK_PACKET 10 /* linux specific way of */
5583 int socket(int domain, int type, int protocol) __THROW;
5584 int accept(int s, struct sockaddr *addr, socklen_t *addrlen) __THROW;
5585 int connect(int sockfd, const struct sockaddr *serv_addr, socklen_t addrlen) __THROW;
5586 @@ -415,7 +563,19 @@
5588 int shutdown(int s, int how) __THROW;
5590 -int socketpair(int d, int type, int protocol, int sv[2]);
5591 +int socketpair(int d, int type, int protocol, int sv[2]) __THROW;
5595 + struct msghdr msg_hdr; /* Message header */
5596 + unsigned int msg_len; /* Number of bytes transmitted */
5599 +int recvmmsg(int sockfd, struct mmsghdr *msgvec, unsigned int vlen,
5600 + unsigned int flags, struct timespec *timeout) __THROW;
5601 +int sendmmsg(int sockfd, struct mmsghdr *msgvec, unsigned int vlen,
5602 + unsigned int flags);
5605 /* currently not supported: */
5607 diff -urN -x .git dietlibc-0.33/include/sys/stat.h dietlibc/include/sys/stat.h
5608 --- dietlibc-0.33/include/sys/stat.h 2012-11-02 11:17:28.000000000 +0000
5609 +++ dietlibc/include/sys/stat.h 2015-01-01 12:14:43.478272229 +0000
5613 #if defined(__i386__)
5617 unsigned long st_ino;
5619 unsigned long long st_ino;
5622 -#elif defined(__x86_64__)
5623 +#elif defined(__x86_64__) && !defined(__ILP32__)
5626 unsigned long st_dev;
5627 @@ -512,6 +513,24 @@
5631 +#elif defined(__x86_64__)
5636 + uint64_t st_dev, st_ino, st_nlink;
5637 + uint32_t st_mode, st_uid, st_gid, __pad0;
5639 + int64_t st_size, st_blksize, st_blocks;
5641 + uint64_t st_atime_nsec;
5643 + uint64_t st_mtime_nsec;
5645 + uint64_t st_ctime_nsec;
5646 + unsigned int __unused[3]
5649 #elif defined(__ia64__)
5653 extern int fstat(int __fd, struct stat *__buf) __THROW;
5654 extern int lstat(const char *__file, struct stat *__buf) __THROW;
5656 -#if __WORDSIZE == 64
5657 +#if (__WORDSIZE == 64) || defined(__OFF_T_MATCHES_OFF64_T)
5660 extern int stat64(const char *__file, struct stat64 *__buf) __THROW;
5661 diff -urN -x .git dietlibc-0.33/include/sys/time.h dietlibc/include/sys/time.h
5662 --- dietlibc-0.33/include/sys/time.h 2008-12-10 20:00:59.000000000 +0000
5663 +++ dietlibc/include/sys/time.h 2015-01-01 12:14:43.481605561 +0000
5665 #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)
5666 #define timersub(a,b,x) do { (x)->tv_sec=(a)->tv_sec-(b)->tv_sec; if (((x)->tv_usec=(a)->tv_usec-(b)->tv_usec)<0) { --(x)->tv_sec; (x)->tv_usec+=1000000; } } while (0)
5667 #define timerisset(x) ((x)->tv_sec || (x)->tv_usec)
5669 -int utimes(const char * filename, struct timeval * tvp);
5672 +int utimes(const char * filename, struct timeval * tvp) __THROW;
5677 diff -urN -x .git dietlibc-0.33/include/sys/tls.h dietlibc/include/sys/tls.h
5678 --- dietlibc-0.33/include/sys/tls.h 2010-09-25 17:03:26.000000000 +0000
5679 +++ dietlibc/include/sys/tls.h 2015-01-01 12:14:43.481605561 +0000
5694 - void *tcb; /* Pointer to the TCB. Not necessary the
5695 - thread descriptor used by libpthread. */
5697 + void *tcb; /* Pointer to the TCB. Accessed as GS:[0], points to itself. */
5698 + dtv_t *dtv; /* Data structure used to find thread-local storage */
5699 void *self; /* Pointer to the thread descriptor. */
5700 - int multiple_threads;
5701 + int multiple_threads; /* Set to 0 by _start/stackgap(), set to 1 by thrd_create */
5704 + int gscope_flag; /* no idea what this is for */
5706 - uintptr_t sysinfo;
5707 - uintptr_t stack_guard;
5708 - uintptr_t pointer_guard;
5709 + uintptr_t sysinfo; /* not sure why this is here; passed via ELF auxvec, copied here by thrd_create */
5710 + uintptr_t stack_guard; /* random value used as canary value by gcc -fstack-protector, initialized by _start/stackgap()/thrd_create */
5711 + uintptr_t pointer_guard; /* random value used by glibc to xor internal pointers as exploit mitigation; not used in dietlibc */
5714 + int gscope_flag; /* no idea what this is for */
5720 int arch_prctl(unsigned int what, void* where);
5722 +#elif defined(__ia64__) || defined(__powerpc64__)
5724 +#define __ABI_TLS_REGISTER "r13"
5726 +#elif defined(__powerpc__)
5728 +#define __ABI_TLS_REGISTER "r2"
5730 +#elif defined(__sparc__)
5732 +#define __ABI_TLS_REGISTER "%g7"
5734 +#elif defined(__arm__)
5736 +void __arm_set_tls(void *);
5740 #warning "need proper sys/tls.h for this platform"
5741 diff -urN -x .git dietlibc-0.33/include/sys/types.h dietlibc/include/sys/types.h
5742 --- dietlibc-0.33/include/sys/types.h 2010-09-25 17:03:26.000000000 +0000
5743 +++ dietlibc/include/sys/types.h 2015-01-01 12:14:43.481605561 +0000
5745 typedef int32_t pid_t; /* Used for process IDs and process group IDs. */
5746 typedef signed long ssize_t; /* Used for a count of bytes or an error indication. */
5747 typedef signed long suseconds_t; /* Used for time in microseconds. */
5748 +#if defined(__x86_64__) && defined(__ILP32__)
5749 +typedef signed long long time_t;
5751 typedef signed long time_t; /* Used for time in seconds. */
5753 typedef signed long useconds_t; /* Used for time in microseconds. */
5755 /* non-susv2 types: */
5757 #if defined _FILE_OFFSET_BITS && _FILE_OFFSET_BITS == 64
5758 typedef off64_t off_t;
5761 +#if defined(__x86_64__) && defined(__ILP32__)
5762 +typedef off64_t off_t;
5764 typedef signed long off_t; /* Used for file sizes. */
5768 __extension__ typedef unsigned long long ino64_t;
5769 __extension__ typedef signed long long blkcnt64_t;
5770 diff -urN -x .git dietlibc-0.33/include/sys/ucontext.h dietlibc/include/sys/ucontext.h
5771 --- dietlibc-0.33/include/sys/ucontext.h 2005-03-11 17:18:15.000000000 +0000
5772 +++ dietlibc/include/sys/ucontext.h 2015-01-01 12:14:43.481605561 +0000
5774 typedef struct sigcontext mcontext_t;
5777 -#if defined(__i386__) || defined(__arm__) || defined(__mips__) || defined(__mips64__) || defined(__powerpc__) || defined(__powerpc64__) || defined(__hppa__)
5778 +#if defined(__i386__) || defined(__x86_64__) || defined(__arm__) || defined(__mips__) || defined(__mips64__) || defined(__powerpc__) || defined(__powerpc64__) || defined(__hppa__)
5780 unsigned long uc_flags;
5781 struct ucontext *uc_link;
5783 struct sigcontext uc_mcontext;
5784 sigset_t uc_sigmask; /* mask last for extensibility */
5785 +#if defined(__i386__) || defined(__x86_64__)
5786 + struct _fpstate __fpregs_mem;
5789 #elif defined(__alpha__)
5791 @@ -105,15 +108,6 @@
5792 #define uc_link uc_mcontext.sc_gr[0] /* wrong type; nobody cares */
5793 #define uc_sigmask uc_mcontext.sc_sigmask
5794 #define uc_stack uc_mcontext.sc_stack
5795 -#elif defined(__x86_64__)
5798 - unsigned long uc_flags;
5799 - struct ucontext *uc_link;
5801 - struct sigcontext uc_mcontext;
5802 - sigset_t uc_sigmask; /* mask last for extensibility */
5806 #error NEED TO PORT <sys/sigcontext.h>!
5807 diff -urN -x .git dietlibc-0.33/include/sys/uio.h dietlibc/include/sys/uio.h
5808 --- dietlibc-0.33/include/sys/uio.h 2003-08-19 16:58:18.000000000 +0000
5809 +++ dietlibc/include/sys/uio.h 2015-01-01 12:14:43.481605561 +0000
5813 /* I have no idea why susv3 specifies count as int instead of size_t */
5814 -ssize_t readv(int filedes, const struct iovec *vector, int count);
5815 -ssize_t writev(int filedes, const struct iovec *vector, int count);
5816 +ssize_t readv(int filedes, const struct iovec *vector, int count) __THROW;
5817 +ssize_t writev(int filedes, const struct iovec *vector, int count) __THROW;
5819 +ssize_t preadv(int fd, const struct iovec *iov, int iovcnt, off_t offset) __THROW;
5820 +ssize_t pwritev(int fd, const struct iovec *iov, int iovcnt, off_t offset) __THROW;
5824 diff -urN -x .git dietlibc-0.33/include/sys/wait.h dietlibc/include/sys/wait.h
5825 --- dietlibc-0.33/include/sys/wait.h 2006-05-29 16:30:53.000000000 +0000
5826 +++ dietlibc/include/sys/wait.h 2015-01-01 12:14:43.481605561 +0000
5828 #define W_STOPCODE(sig) ((sig) << 8 | 0x7f)
5831 -pid_t wait(int *status) __THROW;
5832 -pid_t waitpid(pid_t pid, int *status, int options) __THROW;
5833 +pid_t wait(int *status);
5834 +pid_t waitpid(pid_t pid, int *status, int options);
5836 -pid_t wait3(int *status, int options, struct rusage *rusage) __THROW;
5837 +pid_t wait3(int *status, int options, struct rusage *rusage) __THROWNL;
5839 -pid_t wait4(pid_t pid, int *status, int options, struct rusage *rusage) __THROW;
5840 +pid_t wait4(pid_t pid, int *status, int options, struct rusage *rusage) __THROWNL;
5843 P_ALL, /* Wait for any child. */
5844 diff -urN -x .git dietlibc-0.33/include/threads.h dietlibc/include/threads.h
5845 --- dietlibc-0.33/include/threads.h 1970-01-01 00:00:00.000000000 +0000
5846 +++ dietlibc/include/threads.h 2015-01-01 12:14:43.481605561 +0000
5851 +#include <sys/types.h>
5852 +#include <sys/time.h>
5854 +typedef struct __thrd_t {
5855 + char* memstart; // points to beginning of guard page
5856 + size_t memsize; // this includes the guard page, the stack, the thread local storage but not tcb and thrd_t data
5858 + /* the thread function and the argument it was called with */
5859 + int (*func)(void*);
5861 + /* the return value of the function, so it can be read with pthread_join */
5863 + /* 1: the thread was detached
5864 + * 2: the thread already exited, stack and thread local data freed
5865 + * 4: being torn down (calls to thrd_detach and thrd_join fail) */
5867 + int join_futex,join_wait_futex;
5878 +typedef int (*thrd_start_t)(void* arg);
5880 +int thrd_create(thrd_t *thr, thrd_start_t func, void *arg);
5881 +thrd_t thrd_current(void);
5882 +int thrd_detach(thrd_t thr);
5883 +int thrd_equal(thrd_t thr0, thrd_t thr1);
5884 +void thrd_exit(int res);
5885 +int thrd_join(thrd_t thr, int* res);
5886 +int thrd_sleep(const struct timespec* time_point, struct timespec* remaining);
5887 +void thrd_yield(void);
5889 +typedef struct __mtx_t {
5900 +int mtx_init(mtx_t* mutex, int type);
5901 +int mtx_lock(mtx_t* mutex);
5902 +int mtx_timedlock(mtx_t *restrict mutex, const struct timespec *restrict time_point);
5903 +int mtx_trylock(mtx_t* mutex);
5904 +int mtx_unlock(mtx_t* mutex);
5905 +void mtx_destroy(mtx_t* mutex);
5907 +#ifdef _DIETLIBC_SOURCE
5908 +int __mtx_trylock(mtx_t* mutex,int* lockval);
5911 +typedef int once_flag;
5912 +#define ONCE_FLAG_INIT 0
5914 +void call_once(once_flag* flag, void (*func)(void));
5916 +typedef struct __cnd_t {
5920 +int cnd_init(cnd_t* cond);
5921 +int cnd_signal(cnd_t *cond);
5922 +int cnd_broadcast(cnd_t *cond);
5923 +int cnd_wait(cnd_t* cond, mtx_t* mutex);
5924 +int cnd_timedwait(cnd_t* restrict cond, mtx_t* restrict mutex, const struct timespec* restrict time_point);
5925 +void cnd_destroy(cnd_t* cond);
5927 +#define thread_local __thread
5929 +typedef void (*tss_dtor_t)(void*);
5930 +typedef struct __tss_t {
5933 + struct __tss_t* next;
5936 +#define TSS_DTOR_ITERATIONS 1
5937 +int tss_create(tss_t* tss_id, tss_dtor_t destructor);
5938 +void *tss_get(tss_t tss_id);
5939 +int tss_set(tss_t tss_id, void *val);
5940 +void tss_delete(tss_t tss_id);
5943 diff -urN -x .git dietlibc-0.33/include/ucontext.h dietlibc/include/ucontext.h
5944 --- dietlibc-0.33/include/ucontext.h 1970-01-01 00:00:00.000000000 +0000
5945 +++ dietlibc/include/ucontext.h 2015-01-01 12:14:43.481605561 +0000
5947 +#ifndef _UCONTEXT_H
5948 +#define _UCONTEXT_H
5950 +#include <sys/ucontext.h>
5954 +extern int getcontext (ucontext_t *c) __THROW;
5955 +extern int setcontext (const ucontext_t *c) __THROW;
5956 +extern int swapcontext (ucontext_t *__restrict o,
5957 + const ucontext_t *__restrict n) __THROWNL;
5958 +extern void makecontext (ucontext_t *c, void (*__func) (void),
5959 + int argc, ...) __THROW;
5964 diff -urN -x .git dietlibc-0.33/include/unistd.h dietlibc/include/unistd.h
5965 --- dietlibc-0.33/include/unistd.h 2012-11-02 11:17:28.000000000 +0000
5966 +++ dietlibc/include/unistd.h 2015-01-01 12:14:43.481605561 +0000
5968 #define STDERR_FILENO 2
5970 off_t lseek(int fildes, off_t offset, int whence) __THROW;
5971 -#if __WORDSIZE == 32
5972 +#if !defined(__OFF_T_MATCHES_OFF64_T)
5973 loff_t lseek64(int fildes, loff_t offset, int whence) __THROW;
5974 #if defined _FILE_OFFSET_BITS && _FILE_OFFSET_BITS == 64
5975 #define lseek(fildes,offset,whence) lseek64(fildes,offset,whence)
5978 +#define lseek64(fildes,offset,whence) lseek(fildes,offset,whence)
5981 int chdir(const char *path) __THROW;
5985 char *get_current_dir_name (void) __THROW __attribute_dontuse__;
5987 +int pipe2(int pipefd[2], int flags) __THROW;
5990 int open(const char* pathname,int flags, ...) __THROW;
5992 pid_t setsid (void) __THROW;
5993 int dup (int oldfd) __THROW;
5994 int dup2 (int oldfd,int newfd) __THROW;
5996 +int dup3(int oldfd, int newfd, int flags) __THROW;
5998 +/* flags for memfd_create(2) (unsigned int) */
5999 +#define MFD_CLOEXEC 0x0001U
6000 +#define MFD_ALLOW_SEALING 0x0002U
6002 +int memfd_create(const char* name, unsigned int flags) __THROW;
6006 -int getdents(int fd, struct dirent *dirp, unsigned int count) __THROW;
6007 -int getdents64(int fd, struct dirent64 *dirp, unsigned int count) __THROW;
6008 +int syncfs(int fd) __THROW;
6011 +struct linux_dirent;
6012 +struct linux_dirent64;
6013 +int getdents(int fd, struct linux_dirent *dirp, unsigned int count) __THROW;
6014 +int getdents64(int fd, struct linux_dirent64 *dirp, unsigned int count) __THROW;
6016 pid_t fork(void) __THROW;
6017 pid_t vfork(void) __THROW;
6019 #define _SC_NPROCESSORS_ONLN 6
6020 #define _SC_NPROCESSORS_CONF _SC_NPROCESSORS_ONLN
6021 #define _SC_PHYS_PAGES 7
6022 +#define _SC_GETPW_R_SIZE_MAX 8
6023 +#define _SC_GETGR_R_SIZE_MAX 9
6024 long sysconf(int name) __THROW;
6025 #define _PC_PATH_MAX 1
6026 #define _PC_VDISABLE 2
6031 -#ifdef _LINUX_SOURCE
6032 +#if defined(_LINUX_SOURCE) || defined(_GNU_SOURCE)
6033 int pivot_root(const char *new_root, const char *put_old) __THROW;
6034 /* Linux 2.6 module loading infrastructure:
6035 * init_module takes a buffer where you read the module file into */
6036 @@ -270,8 +287,19 @@
6037 int tkill(pid_t tid, int sig) __THROW;
6038 int tgkill(pid_t tgid, pid_t tid, int sig) __THROW;
6039 /* see linux/fadvise.h */
6040 -long fadvise64(int fd,off64_t offset,size_t len,int advice);
6041 -long fadvise64_64(int fd,off64_t offset,off64_t len,int advice);
6042 +long fadvise64(int fd,off64_t offset,size_t len,int advice) __THROW;
6043 +long fadvise64_64(int fd,off64_t offset,off64_t len,int advice) __THROW;
6045 +#ifndef GRND_NONBLOCK
6048 +#define GRND_NONBLOCK GRND_NONBLOCK
6050 +#define GRND_RANDOM GRND_RANDOM
6053 +int getrandom(void* buf, size_t buflen, unsigned int flags) __THROW;
6057 #if defined(_ATFILE_SOURCE) || ((_XOPEN_SOURCE + 0) >= 700) || ((_POSIX_C_SOURCE + 0) >= 200809L)
6058 diff -urN -x .git dietlibc-0.33/include/wchar.h dietlibc/include/wchar.h
6059 --- dietlibc-0.33/include/wchar.h 2010-09-25 17:03:26.000000000 +0000
6060 +++ dietlibc/include/wchar.h 2015-01-01 12:14:43.481605561 +0000
6063 typedef unsigned int wint_t;
6065 -typedef int (*wctype_t)(wint_t) __THROW __attribute__((__const__));
6066 +typedef int (*wctype_t)(wint_t) __attribute__((__const__)) __THROW;
6069 #define WCHAR_MIN (-2147483647 - 1)
6070 diff -urN -x .git dietlibc-0.33/ldso.c dietlibc/ldso.c
6071 --- dietlibc-0.33/ldso.c 1970-01-01 00:00:00.000000000 +0000
6072 +++ dietlibc/ldso.c 2015-01-01 12:14:43.481605561 +0000
6074 +#define errno fnord
6075 +#include <unistd.h>
6077 +#include <sys/mman.h>
6079 +#include <stdlib.h>
6080 +#include <stdint.h>
6083 +#if (__WORDSIZE == 64)
6085 +#define phdr Elf64_Phdr
6086 +#define ehdr Elf64_Ehdr
6087 +#define shdr Elf64_Shdr
6088 +#define sym Elf64_Sym
6089 +#define dyn Elf64_Dyn
6090 +#define rela Elf64_Rela
6091 +#define R_SYM ELF64_R_SYM
6092 +#define R_TYPE ELF64_R_TYPE
6096 +#define phdr Elf32_Phdr
6097 +#define ehdr Elf32_Ehdr
6098 +#define shdr Elf32_Shdr
6099 +#define sym Elf32_Sym
6100 +#define dyn Elf32_Dyn
6101 +#define rela Elf32_Rela
6102 +#define R_SYM ELF32_R_SYM
6103 +#define R_TYPE ELF32_R_TYPE
6108 +__attribute__((visibility("hidden"))) int* __errno_location(void) { return &errno; }
6110 +static size_t _strlen(const char* s) {
6112 + for (i=0; s[i]; ++i);
6115 +static char* _stpcpy(char* dest,const char* src) {
6117 + for (i=0; src[i]; ++i)
6122 +static char* _strchr(char* s,char c) {
6124 + for (i=0; s[i] && s[i]!=c; ++i) ;
6125 + if (s[i]==c) return s+i; else return NULL;
6127 +static int _strcmp(const void* str1,const void* str2) {
6128 + const unsigned char* a=str1;
6129 + const unsigned char* b=str2;
6132 + for (i=0; (r=(a[i]-b[i]))==0 && a[i]; ++i) ;
6135 +static int _memcmp(const void* dst,const void* src,size_t count) {
6136 + const unsigned char* a=dst;
6137 + const unsigned char* b=src;
6140 + for (i=0; i<count && (r=(a[i]-b[i]))==0; ++i) ;
6143 +static void* _memcpy(void* dst,const void* src,size_t len) {
6145 + const char* b=src;
6147 + for (i=0; i<len; ++i)
6151 +static void _memset(void* dst,unsigned char c,size_t len) {
6152 + unsigned char* a=dst;
6154 + for (i=0; i<len; ++i) a[i]=c;
6156 +static ssize_t __write1(const char* s) {
6157 + write(1,s,_strlen(s));
6159 +static ssize_t __write2(const char* s) {
6160 + write(2,s,_strlen(s));
6163 +ssize_t write(int fd,const void* buf,size_t len) __attribute__((visibility("hidden")));
6164 +int open(const char* pathname,int flags, ...) __attribute__((visibility("hidden")));
6165 +ssize_t read(int fd,void* buf,size_t len) __attribute__((visibility("hidden")));
6166 +int close(int fd) __attribute__((visibility("hidden")));
6167 +ssize_t pread64(int fd, void *buf, size_t count, off64_t offset) __attribute__((visibility("hidden")));;
6168 +void *mmap(void *__addr, size_t __len, int __prot, int __flags, int __fd, off_t __offset) __attribute__((visibility("hidden")));
6169 +int munmap(void *__addr, size_t __len) __attribute__((visibility("hidden")));
6170 +int mprotect (void *__addr, size_t __len, int __prot) __attribute__((visibility("hidden")));
6171 +void exit(int res) __attribute__((visibility("hidden")));
6173 +static struct page {
6174 + struct page* next;
6176 + char data[4096-sizeof(size_t)-sizeof(struct page*)];
6179 +static void* _malloc(size_t l) {
6181 + if (l>sizeof(heap->data)) return 0;
6182 + if (l%(sizeof(void*)*2)) {
6183 + l += sizeof(void*)*2;
6184 + l -= l%(sizeof(void*)*2);
6186 + for (p=&heap; *p && (*p)->a<l; p=&((*p)->next)) ;
6188 + void* tmp=mmap(0,4096,PROT_READ|PROT_WRITE,MAP_ANONYMOUS|MAP_PRIVATE,-1,0);
6189 + if (tmp==MAP_FAILED) return 0;
6191 + (*p)->a=sizeof(heap->data);
6193 + if (l <= (*p)->a) {
6194 + char* tmp=(*p)->data+sizeof((*p)->data)-(*p)->a;
6198 + return 0; // can't happen
6201 +static char path[100];
6204 +static struct dll {
6207 + void* code,* data;
6208 + size_t codelen,datalen,codeplus;
6209 + char name[1]; // asciiz of library name
6212 +static int map_sections(int fd,const ehdr* e,const phdr* p,struct dll* D) {
6214 + uintptr_t codeplus=0;
6216 + for (i=0; i<e->e_phnum; ++i) {
6217 + if (p[i].p_type==PT_LOAD) {
6218 + size_t delta=p[i].p_offset%4096;
6219 + size_t maplen=p[i].p_filesz+delta;
6220 + size_t bssdiff=(p[i].p_filesz+delta)%4096;
6222 + if ((p[i].p_flags&PF_W) && (p[i].p_flags&PF_X)) {
6223 + __write2("section is both executable and writable, aborting!\n");
6226 + if (!(p[i].p_flags&PF_W)) {
6227 + /* code segment */
6228 + size_t ofs,len,rolen=0,nolen=0,rolen2=0,vaddr=p[i].p_vaddr,baseofs=0;
6229 + /* the first segment will be the code segment, and it will have
6230 + * either a fixed address or 0 if it's a shared library. We
6231 + * insist that the mapping start at file offset 0, and we extend
6232 + * the mapping so it includes the section table */
6233 + ofs=p[i].p_offset;
6234 + len=p[i].p_filesz;
6236 + __write2("can't happen error: ofs!=0\n");
6246 + if (ofs+len < e->e_shoff+e->e_shnum*e->e_shentsize) {
6247 + size_t needed=e->e_shoff+e->e_shnum*e->e_shentsize;
6248 + /* if this mapping does not include the section table is not
6249 + * included, extend the mapping to include it */
6250 + rolen2=e->e_shnum*e->e_shentsize;
6251 + if (rolen2>needed-len)
6252 + /* we were almost there, part of the section table was
6253 + * already mapped */
6254 + rolen2=needed-len;
6256 + nolen=needed-len-rolen2;
6258 + * +------------------------+
6259 + * | rolen e-> | if the mapping did not start at beginning of file, this is the beginning of file, PROT_READ
6260 + * +------------------------+
6261 + * | len base-> | this is the actual mapping, base points here, PROT_READ|PROT_EXEC
6262 + * +------------------------+
6263 + * | nolen | stuff we don't really need and will mprotect PROT_NONE
6264 + * +------------------------+
6265 + * | rolen2 e+e->shoff | the section header table, PROT_READ
6266 + * +------------------------+
6269 + c=mmap((char*)vaddr,rolen+len+nolen+rolen2,
6270 + ((p[i].p_flags&PF_R)?PROT_READ:0) |
6271 + ((p[i].p_flags&PF_X)?PROT_EXEC:0),
6272 + MAP_SHARED|(vaddr?MAP_FIXED:0),
6274 + /* in case the can't happen branch ever happens */
6276 + D->code=c+rolen; D->codelen=len;
6277 +// D->s=(shdr*)(c+e->e_shoff);
6278 + if (rolen>=4096) /* if we extended the mapping in the front, remove exec permissions */
6279 + mprotect(c,rolen&~4095,PROT_READ);
6280 + if (!vaddr && !codeplus) codeplus=(uintptr_t)(c+rolen);
6282 + /* We mapped junk in the middle.
6283 + * If there are full pages in there, map them PROT_NONE */
6284 + char* start=c+rolen+len;
6286 + size_t diff=(-(uintptr_t)start & 4095);
6287 + if (diff < nolen) {
6288 + /* diff is the part at the beginning we need to skip because
6289 + * it's on a page we actually need to be executable.
6290 + * Now find out if we overshoot onto a page we want */
6291 + size_t removeatend=((uintptr_t)c+rolen+len)&4095;
6292 + mprotect(start+diff,len-diff-removeatend,PROT_NONE);
6296 + /* Now we want to mprotect PROT_READ the section table.
6297 + * What makes this complex is that mprotect granularity is one
6298 + * page. First figure out the region we are interested in. */
6299 + char* start=c+rolen+len+nolen;
6300 + size_t len=rolen2;
6301 + /* we want to mprotect from start to start+len */
6302 + int diff=((uintptr_t)start)&4095;
6303 + /* This is the offset of start from the page start. We need
6304 + * to mprotect the whole page -- unless it also has code on
6305 + * it, in which case we need to leave it alone */
6306 + if (diff > nolen) {
6307 + size_t roundup=(-(uintptr_t)start)&4095;
6308 + /* we need to skip the first page. Let's see if there is
6309 + * anything left in that case */
6311 + if (rolen2>roundup)
6319 + if (len) mprotect(start,len,PROT_READ);
6321 + } else if (p[i].p_flags&PF_W) { /* data segment */
6322 + /* We have already mapped the code segment to base.
6323 + * For programs, the base mapping of the code and data segment
6324 + * is absolute and we just map there with MAP_FIXED. For shared
6325 + * libraries however, the base mapping of the code segment is 0,
6326 + * and the vaddr of the data segment is not absolute but
6327 + * relative to the code segment */
6329 + /* The data segment may not start on a page boundary. Round
6330 + * start address if necessary. */
6331 + size_t addr,ofs,len,memsetstart=0,memsetend=0,additional=0;
6332 + addr=p[i].p_vaddr+codeplus;
6333 + ofs=p[i].p_offset;
6334 + len=p[i].p_filesz;
6335 + if ((memsetstart=(ofs%4096))) {
6338 + addr-=memsetstart;
6341 + /* The data segment consists of actual data, but a part of it is
6342 + * data initialized to 0, the .bss section. This section is not
6343 + * actually put in the file to save space, but the ELF loader
6344 + * (that's us) is expected to allocate that data at program
6346 + memsetend=p[i].p_memsz-p[i].p_filesz;
6348 + /* We have a .bss. We need to handle two cases. First: if
6349 + * the number of bytes is small enough to fit on the last page
6350 + * we already mapped for the data, all we need to do is memset
6351 + * it. Otherwise we needto memset the rest of that page and
6352 + * map some additional pages after it. */
6353 + size_t bytes_on_last_page=(-len)&4095;
6354 + if (memsetend<bytes_on_last_page)
6357 + len+=bytes_on_last_page;
6358 + additional=memsetend-bytes_on_last_page;
6359 + memsetend=bytes_on_last_page;
6363 + c=mmap((char*)addr,len,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_FIXED,fd,ofs);
6364 + if (c==MAP_FAILED) {
6365 + __write2("mmap failed!\n");
6369 + if (memsetstart) _memset(c,0,memsetstart);
6370 + if (memsetend) _memset(c+len-memsetend,0,memsetend);
6372 + char* tmp=mmap(c+len,additional,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANONYMOUS,-1,0);
6373 + if (tmp==MAP_FAILED) {
6374 + __write2("mmap failed!\n");
6378 + D->data=c+memsetstart; D->datalen=len-memsetstart;
6379 + D->codeplus=codeplus;
6381 + __write2("can't happen error: LOAD segment that is neither code nor data.\n");
6390 +static int __loadlibrary(const char* fn) {
6398 + char* code=0,* data=0;
6400 + size_t codelen,datalen;
6402 + __write1("trying ");
6406 + fd=open(fn,O_RDONLY);
6407 + if (fd==-1) return -1;
6408 + if (read(fd,buf,1000)<1000) {
6413 + if (_memcmp(buf,"\177ELF",4)) goto kaputt;
6416 + if (e->e_ident[4] != (sizeof(size_t)/4) || // wrong word size
6417 + e->e_type != ET_DYN || // not shared object
6418 + e->e_machine != // for different architecture
6419 +#if defined(__x86_64__)
6421 +#elif defined(__i386__)
6424 +#error architecture not recognized, please add
6427 + e->e_phentsize != sizeof(phdr) || // wrong program header entry size
6428 + e->e_phnum > 20 || // too many program header entries
6429 + e->e_shentsize !=sizeof(shdr) || // wrong section header entry size
6430 + e->e_shnum > 100) // too many sections
6434 + if (e->e_phoff>=1000 || e->e_phentsize*e->e_phnum>1000-e->e_phoff) {
6435 + size_t wanted=e->e_phentsize*e->e_phnum;
6437 + if (pread64(fd,p,wanted,e->e_phoff)!=wanted)
6440 + p=(phdr*)(buf+e->e_phoff);
6443 + if (map_sections(fd,e,p,&dll)) {
6444 + __write2("map_sections failed\n");
6452 + for (i=0; fn[i]; ++i)
6453 + if (fn[i]=='/') tmp=fn+i;
6455 + D=_malloc(sizeof(struct dll)+_strlen(tmp));
6456 + _stpcpy(D->name,tmp);
6459 + D->code=dll.code; D->codelen=dll.codelen;
6460 + D->data=dll.data; D->datalen=dll.datalen;
6463 + D->codeplus=dll.codeplus;
6466 + for (x=&dlls; *x; x=&(*x)->next) ;
6472 +static int loadlibrary(const char* fn) {
6476 + const char* shortname=fn;
6481 + for (i=0; fn[i]; ++i)
6482 + if (fn[i]=='/') shortname=fn+i+1;
6485 + if (_strlen(fn)>50) return -1;
6486 + for (d=dlls; d; d=d->next)
6487 + if (!_strcmp(d->name,shortname))
6490 + __write1("loadlibrary(\"");
6492 + __write1("\")\n");
6494 + return __loadlibrary(fn);
6497 + c=_stpcpy(lp,path);
6500 + r=__loadlibrary(lp);
6501 + if (r==0) return r;
6506 + for (i=0; ; ++i) {
6508 + if (c[i]==':' || c[i]==0) {
6511 + _stpcpy(lp+i+1,fn);
6512 + r=__loadlibrary(lp);
6515 + if (c[i]==0) break;
6516 + c+=i+1; i=0; goto again;
6518 + if (i<100) lp[i]=c[i];
6524 +static int loadlibs(struct dll* D) {
6526 + phdr* p=(phdr*)((char*)D->e+D->e->e_phoff);
6528 + size_t dnum,dynstrlen;
6531 + /* we know we have exactly one code and exactly one data segment,
6532 + * otherwise we wouldn't have gotten this far */
6533 + for (i=0; i<D->e->e_phnum; ++i)
6534 + if (p[i].p_type==PT_DYNAMIC) {
6535 + d=(dyn*)((char*)p[i].p_vaddr+D->codeplus);
6536 + dnum=p[i].p_memsz/sizeof(dyn);
6539 + for (i=0; i<dnum; ++i)
6540 + if (d[i].d_tag==DT_STRTAB) {
6541 + dynstr=(char*)d[i].d_un.d_ptr+D->codeplus;
6543 + } else if (d[i].d_tag==DT_NULL)
6546 + /* we now have a dynamic section we can traverse */
6547 + for (i=0; i<dnum; ++i) {
6548 + if (d[i].d_tag==DT_NEEDED) {
6549 + if (loadlibrary(dynstr+d[i].d_un.d_val)) {
6550 + __write2("library ");
6551 + __write2(dynstr+d[i].d_un.d_val);
6552 + __write2(" not found!\n");
6555 + } else if (d[i].d_tag==DT_NULL)
6562 +static unsigned int elf_hash(const unsigned char *name) {
6563 + unsigned int h=0, g;
6566 + h = (h<<4) + *(name++);
6567 + if ((g = h&0xf0000000)) h ^= g>>24;
6573 +static uint_fast32_t gnu_hash(const unsigned char *s) {
6575 + uint_fast32_t h=5381;
6576 + for(c=*s;(c!='\0');c=*++s) {
6580 + return (h&0xffffffff);
6583 +static char* dlsym_int(const char* symbol,struct dll* x) {
6584 + for (; x; x=x->next) {
6588 + phdr* p=(phdr*)(x->e->e_phoff+(char*)x->e);
6589 + const char* strtab;
6592 + for (i=0; i<x->e->e_phnum; ++i)
6593 + if (p[i].p_type==PT_DYNAMIC) {
6594 + d=(dyn*)(x->codeplus + p[i].p_vaddr);
6595 + dnum=p[i].p_memsz/sizeof(dyn);
6599 + for (i=0; i<dnum; ++i) {
6600 + if (d[i].d_tag == DT_HASH)
6601 + hash=(int*)((char*)x->codeplus + d[i].d_un.d_ptr);
6602 + else if (d[i].d_tag == DT_SYMTAB)
6603 + sy=(sym*)((char*)(x->codeplus+d[i].d_un.d_ptr));
6604 + else if (d[i].d_tag == DT_STRTAB)
6605 + strtab=(char*)(x->codeplus+d[i].d_un.d_ptr);
6608 + /* hash[0] is the number of buckets. */
6609 + /* hash[1] is the hash chain length, not used here */
6610 + size_t bhash=elf_hash(symbol)%hash[0];
6611 + unsigned int* chain=hash+2+hash[0];
6612 + unsigned int index;
6613 + for (index=(hash+2)[bhash]; index; index=chain[index]) {
6615 + __write1(strtab+sy[index].st_name); __write1("\n");
6617 + if (sy[index].st_value && sy[index].st_shndx!=SHN_UNDEF && !_strcmp(strtab+sy[index].st_name,symbol)) {
6618 + return (char*)x->codeplus+sy[index].st_value;
6623 + __write1(" ... next: ");
6624 + __write1(x->next->name);
6632 +static void* dlsym(const char* s) {
6633 + return dlsym_int(s,&dllroot);
6636 +static void* _dlsym(const char* s) {
6639 + __write2("ld.so: lookup of symbol \"");
6641 + __write2("\" failed.\n");
6647 +static void resolve(struct dll* D) {
6649 + phdr* p=(phdr*)((char*)D->e+D->e->e_phoff);
6651 + size_t dnum,dynstrlen,rnum=0;
6652 + char* dynstr=0, *pltgot=0, *pltrel=0;
6656 + /* we know we have exactly one code and exactly one data segment,
6657 + * otherwise we wouldn't have gotten this far */
6658 + for (i=0; i<D->e->e_phnum; ++i)
6659 + if (p[i].p_type==PT_DYNAMIC) {
6660 + d=(dyn*)((char*)p[i].p_vaddr+D->codeplus);
6661 + dnum=p[i].p_memsz/sizeof(dyn);
6664 + for (i=0; i<dnum; ++i)
6665 + if (d[i].d_tag==DT_STRTAB)
6666 + dynstr=(char*)d[i].d_un.d_ptr+D->codeplus;
6667 + else if (d[i].d_tag==DT_RELA)
6668 + r=(rela*)((char*)d[i].d_un.d_ptr+D->codeplus);
6669 + else if (d[i].d_tag==DT_RELASZ)
6670 + rnum=d[i].d_un.d_val/sizeof(rela);
6671 + else if (d[i].d_tag==DT_SYMTAB)
6672 + symtab=(sym*)((char*)d[i].d_un.d_ptr+D->codeplus);
6673 + else if (d[i].d_tag==0)
6676 + for (i=0; i<rnum; ++i) {
6677 + size_t* x=(size_t*)((char*)(r[i].r_offset+D->codeplus));
6679 + size_t sym=R_SYM(r[i].r_info);
6680 + switch (R_TYPE(r[i].r_info)) {
6681 +#if defined(__x86_64__)
6683 + *x=D->codeplus+symtab[sym].st_value;
6685 + case R_X86_64_COPY:
6686 + y=dlsym_int(symtab[sym].st_name+dynstr,D->next);
6687 + if (!y && ELF32_ST_BIND(symtab[sym].st_info) != STB_WEAK) {
6688 + __write2("symbol lookup failed: ");
6689 + __write2(dynstr+symtab[sym].st_name);
6693 + _memcpy(x,y,symtab[sym].st_size);
6695 + case R_X86_64_GLOB_DAT:
6696 + case R_X86_64_JUMP_SLOT:
6697 + y=dlsym(symtab[sym].st_name+dynstr);
6698 + if (!y && ELF32_ST_BIND(symtab[sym].st_info) != STB_WEAK) {
6699 + __write2("symbol lookup failed: ");
6700 + __write2(dynstr+symtab[sym].st_name);
6706 + case R_X86_64_RELATIVE:
6707 + *x=r[i].r_addend+D->codeplus;
6710 + *(uint32_t*)x=*(uint32_t*)_dlsym(symtab[sym].st_name+dynstr)+r[i].r_addend;
6713 + __write2("unknown relocation type!\n");
6717 +#error fixme: add relocation types for your platform
6725 +int main(int argc,char* argv[],char* envp[]) {
6732 + phdr* code=0,* data=0;
6742 + fd=open("/proc/self/maps",O_RDONLY);
6746 + l=read(fd,buf,sizeof(buf));
6748 + } while (l==sizeof(buf));
6754 + __write2("usage: ld.so /path/to/binary\n");
6757 + fd=open("/etc/diet.ld.conf",O_RDONLY);
6759 + int r=read(fd,path,99);
6760 + if (r>0) path[r]=0;
6761 + while (r>0 && path[r-1]=='\n') path[--r]=0;
6764 + for (i=0; envp[i]; ++i) {
6765 + if (_memcmp(envp[i],"LD_LIBRARY_PATH=",16)==0)
6768 + fd=open(argv[1],O_RDONLY);
6770 + __write2("could not open \"");
6771 + __write2(argv[1]);
6772 + __write2("\".\n");
6775 + l=read(fd,buf,1000);
6776 + if (l<sizeof(ehdr) || _memcmp(buf,"\177ELF",4)) {
6778 + __write2("invalid ELF file \"");
6784 + if (e->e_ident[4] != (sizeof(size_t)/4)) {
6785 + __write2("wrong word size!\n");
6789 + if (e->e_ident[7] != ELFOSABI_LINUX) {
6790 + __write2("ABI not Linux!\n");
6794 + if (e->e_type != ET_EXEC) {
6795 + __write2("not an executable!\n");
6798 + if (e->e_machine !=
6799 +#if defined(__x86_64__)
6801 +#elif defined(__i386__)
6804 +#error architecture not recognized, please add
6807 + __write2("invalid architecture!\n");
6811 + if (e->e_phentsize != sizeof(phdr)) {
6812 + __write2("invalid phentsize!\n");
6815 + if (e->e_phnum > 20) {
6816 + __write2("phnum too large!\n");
6819 + if (e->e_shentsize != sizeof(shdr)) {
6820 + __write2("invalid shentsize!\n");
6823 + if (e->e_shnum > 100) {
6824 + __write2("shnum too large!\n");
6828 + if (e->e_phoff>=l || e->e_phentsize*e->e_phnum>l-e->e_phoff) {
6829 + size_t wanted=e->e_phentsize*e->e_phnum;
6831 + if (pread64(fd,p,wanted,e->e_phoff)!=wanted)
6834 + p=(phdr*)(buf+e->e_phoff);
6837 + if (map_sections(fd,e,p,&dllroot)) {
6838 + __write2("map_sections failed!\n");
6843 + loadlibs(&dllroot);
6845 + /* now load the prerequisites of the libraries we loaded */
6848 + for (x=dlls; x; x=x->next) {
6853 + resolve(&dllroot);
6855 + __write2("jumping...\n");
6858 + int (*_init)(int argc,char* argv[],char* envp[])=(void*)(e->e_entry+dllroot.codeplus);
6859 + return _init(argc,argv,envp);
6863 + char* x=dlsym("theint");
6864 + __write1("done\n");
6869 + printf("jump to %p\n",e->e_entry);
6870 + for (i=0; i<16; ++i) {
6871 + printf("%02x ",((unsigned char*)e->e_entry)[i]);
6877 diff -urN -x .git dietlibc-0.33/lib/alloc.c dietlibc/lib/alloc.c
6878 --- dietlibc-0.33/lib/alloc.c 2007-10-17 11:47:57.000000000 +0000
6879 +++ dietlibc/lib/alloc.c 2015-01-01 12:14:43.481605561 +0000
6884 -#include <sys/shm.h> /* for PAGE_SIZE */
6886 +#include "../dietpagesize.h"
6888 /* -- HELPER CODE --------------------------------------------------------- */
6891 #define BLOCK_START(b) (((void*)(b))-sizeof(__alloc_t))
6892 #define BLOCK_RET(b) (((void*)(b))+sizeof(__alloc_t))
6894 -#define MEM_BLOCK_SIZE PAGE_SIZE
6895 +#define MEM_BLOCK_SIZE __DIET_PAGE_SIZE
6896 #define PAGE_ALIGN(s) (((s)+MEM_BLOCK_SIZE-1)&(unsigned long)(~(MEM_BLOCK_SIZE-1)))
6898 /* a simple mmap :) */
6901 #define FIRST_SMALL(p) (((unsigned long)(p))&(~(MEM_BLOCK_SIZE-1)))
6903 -static inline int __ind_shift() { return (MEM_BLOCK_SIZE==4096)?4:5; }
6904 +static inline int __ind_shift() {
6905 + return __DIET_PAGE_SHIFT - sizeof(__small_mem)/sizeof(__small_mem[0]);
6908 static size_t REGPARM(1) get_index(size_t _size) {
6909 register size_t idx=0;
6912 void __libc_free(void *ptr) __attribute__((alias("_alloc_libc_free")));
6913 void free(void *ptr) __attribute__((weak,alias("_alloc_libc_free")));
6914 -void if_freenameindex(void* ptr) __attribute__((alias("free")));
6916 #ifdef WANT_MALLOC_ZERO
6917 static __alloc_t zeromem[2];
6918 diff -urN -x .git dietlibc-0.33/lib/call_once.c dietlibc/lib/call_once.c
6919 --- dietlibc-0.33/lib/call_once.c 1970-01-01 00:00:00.000000000 +0000
6920 +++ dietlibc/lib/call_once.c 2015-01-01 12:14:43.481605561 +0000
6922 +#include <threads.h>
6924 +void call_once(once_flag* flag, void (*func)(void)) {
6925 + if (__sync_bool_compare_and_swap(flag,0,1))
6928 diff -urN -x .git dietlibc-0.33/lib/closedir.c dietlibc/lib/closedir.c
6929 --- dietlibc-0.33/lib/closedir.c 2002-07-03 20:33:37.000000000 +0000
6930 +++ dietlibc/lib/closedir.c 2015-01-01 12:14:43.484938895 +0000
6935 +#include "../dietpagesize.h"
6937 int closedir (DIR* d) {
6938 int res=close(d->fd);
6939 - munmap (d, PAGE_SIZE);
6940 + munmap (d, __DIET_PAGE_SIZE);
6943 diff -urN -x .git dietlibc-0.33/lib/cnd_broadcast.c dietlibc/lib/cnd_broadcast.c
6944 --- dietlibc-0.33/lib/cnd_broadcast.c 1970-01-01 00:00:00.000000000 +0000
6945 +++ dietlibc/lib/cnd_broadcast.c 2015-01-01 12:14:43.484938895 +0000
6947 +#include <threads.h>
6948 +#include <sys/futex.h>
6950 +int cnd_broadcast(cnd_t* cond) {
6952 + futex(&cond->sem,FUTEX_WAKE,0x7fffffff,0,0,0);
6953 + return thrd_success;
6955 diff -urN -x .git dietlibc-0.33/lib/cnd_destroy.c dietlibc/lib/cnd_destroy.c
6956 --- dietlibc-0.33/lib/cnd_destroy.c 1970-01-01 00:00:00.000000000 +0000
6957 +++ dietlibc/lib/cnd_destroy.c 2015-01-01 12:14:43.484938895 +0000
6959 +#include <threads.h>
6961 +void cnd_destroy(cnd_t* cond) {
6962 + // no need to do anything
6965 diff -urN -x .git dietlibc-0.33/lib/cnd_init.c dietlibc/lib/cnd_init.c
6966 --- dietlibc-0.33/lib/cnd_init.c 1970-01-01 00:00:00.000000000 +0000
6967 +++ dietlibc/lib/cnd_init.c 2015-01-01 12:14:43.484938895 +0000
6969 +#include <threads.h>
6971 +int cnd_init(cnd_t* cond) {
6973 + return thrd_success;
6975 diff -urN -x .git dietlibc-0.33/lib/cnd_signal.c dietlibc/lib/cnd_signal.c
6976 --- dietlibc-0.33/lib/cnd_signal.c 1970-01-01 00:00:00.000000000 +0000
6977 +++ dietlibc/lib/cnd_signal.c 2015-01-01 12:14:43.484938895 +0000
6979 +#include <threads.h>
6980 +#include <sys/futex.h>
6982 +int cnd_signal(cnd_t* cond) {
6984 + futex(&cond->sem,FUTEX_WAKE,1,0,0,0);
6985 + return thrd_success;
6987 diff -urN -x .git dietlibc-0.33/lib/cnd_timedwait.c dietlibc/lib/cnd_timedwait.c
6988 --- dietlibc-0.33/lib/cnd_timedwait.c 1970-01-01 00:00:00.000000000 +0000
6989 +++ dietlibc/lib/cnd_timedwait.c 2015-01-01 12:14:43.484938895 +0000
6991 +#include <threads.h>
6992 +#include <sys/futex.h>
6995 +int cnd_timedwait(cnd_t* cond, mtx_t* mutex, const struct timespec* time_point) {
6998 + r=futex(&cond->sem,FUTEX_WAIT,0,time_point,0,0);
7000 + if (errno==EWOULDBLOCK) { r=0; break; }
7001 + else if (errno==EINTR) continue;
7006 + return mtx_timedlock(mutex,time_point);
7008 diff -urN -x .git dietlibc-0.33/lib/cnd_wait.c dietlibc/lib/cnd_wait.c
7009 --- dietlibc-0.33/lib/cnd_wait.c 1970-01-01 00:00:00.000000000 +0000
7010 +++ dietlibc/lib/cnd_wait.c 2015-01-01 12:14:43.484938895 +0000
7012 +#include <threads.h>
7013 +#include <sys/futex.h>
7016 +int cnd_wait(cnd_t* cond, mtx_t* mutex) {
7017 + return cnd_timedwait(cond,mutex,0);
7019 diff -urN -x .git dietlibc-0.33/lib/__dtostr.c dietlibc/lib/__dtostr.c
7020 --- dietlibc-0.33/lib/__dtostr.c 2006-09-14 16:29:22.000000000 +0000
7021 +++ dietlibc/lib/__dtostr.c 2015-01-01 12:14:43.481605561 +0000
7024 static int copystring(char* buf,int maxlen, const char* s) {
7026 - for (i=0; i<3&&i<maxlen; ++i)
7027 + for (i=0; i<maxlen; ++i) {
7029 - if (i<maxlen) { buf[i]=0; ++i; }
7036 -int __dtostr(double d,char *buf,unsigned int maxlen,unsigned int prec,unsigned int prec2,int g) {
7037 +int __dtostr(double d,char *buf,unsigned int maxlen,unsigned int prec,unsigned int prec2,int flags) {
7040 unsigned long long l;
7045 - if ((i=isinf(d))) return copystring(buf,maxlen,i>0?"inf":"-inf");
7046 - if (isnan(d)) return copystring(buf,maxlen,"nan");
7048 + return copystring(buf,maxlen,
7050 + (flags&0x02?"-INF":"-inf"):
7051 + (flags&0x02?"INF":"inf"));
7052 + if (isnan(d)) return copystring(buf,maxlen,flags&0x02?"NAN":"nan");
7053 e10=1+(long)(e*0.30102999566398119802); /* log10(2) */
7054 /* Wir iterieren von Links bis wir bei 0 sind oder maxlen erreicht
7055 * ist. Wenn maxlen erreicht ist, machen wir das nochmal in
7057 if (prec2 || prec>(unsigned int)(buf-oldbuf)+1) { /* more digits wanted */
7058 if (!maxlen) return 0; --maxlen;
7061 + if ((flags & 0x01)) {
7062 if (prec2) prec=prec2;
7065 diff -urN -x .git dietlibc-0.33/lib/errno.c dietlibc/lib/errno.c
7066 --- dietlibc-0.33/lib/errno.c 1970-01-01 00:00:00.000000000 +0000
7067 +++ dietlibc/lib/errno.c 2015-01-01 12:14:43.484938895 +0000
7071 +#include "errno_definition.h"
7072 diff -urN -x .git dietlibc-0.33/lib/errno_location.c dietlibc/lib/errno_location.c
7073 --- dietlibc-0.33/lib/errno_location.c 2001-06-07 12:29:35.000000000 +0000
7074 +++ dietlibc/lib/errno_location.c 2015-01-01 12:14:43.484938895 +0000
7077 +#include <sys/tls.h>
7078 +#include <threads.h>
7081 -int *__errno_location(void) __attribute__((weak));
7082 -int *__errno_location() { return &errno; }
7083 +// int *__errno_location(void) __attribute__((weak));
7084 +__attribute__((weak)) int *__errno_location(void) { return &errno; }
7086 diff -urN -x .git dietlibc-0.33/lib/eventfd.c dietlibc/lib/eventfd.c
7087 --- dietlibc-0.33/lib/eventfd.c 1970-01-01 00:00:00.000000000 +0000
7088 +++ dietlibc/lib/eventfd.c 2015-01-01 12:14:43.484938895 +0000
7090 +#include <sys/types.h>
7093 +#include <sys/eventfd.h>
7095 +extern int __eventfd(unsigned int count);
7096 +extern int __eventfd2(unsigned int count,int flags);
7098 +int eventfd(unsigned int count,int flags) {
7099 + int r=__eventfd2(count,flags);
7100 + if (r==-1 && errno==ENOSYS) {
7101 + r=__eventfd(count);
7102 + if (r!=-1 && flags) {
7104 + x=fcntl(r,F_SETFD,flags);
7111 diff -urN -x .git dietlibc-0.33/lib/fdopendir.c dietlibc/lib/fdopendir.c
7112 --- dietlibc-0.33/lib/fdopendir.c 2012-01-15 19:20:56.000000000 +0000
7113 +++ dietlibc/lib/fdopendir.c 2015-01-01 12:14:43.484938895 +0000
7115 #include "dietdirent.h"
7116 +#include "dietpagesize.h"
7117 #include <sys/mman.h>
7124 - t = (DIR *) mmap (NULL, PAGE_SIZE, PROT_READ | PROT_WRITE,
7125 + t = (DIR *) mmap (NULL, __DIET_PAGE_SIZE, PROT_READ | PROT_WRITE,
7126 MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
7127 - if (t == MAP_FAILED)
7131 + if (t != MAP_FAILED)
7135 diff -urN -x .git dietlibc-0.33/lib/__get_cur_tcb.c dietlibc/lib/__get_cur_tcb.c
7136 --- dietlibc-0.33/lib/__get_cur_tcb.c 1970-01-01 00:00:00.000000000 +0000
7137 +++ dietlibc/lib/__get_cur_tcb.c 2015-01-01 12:14:43.481605561 +0000
7139 +#include <sys/tls.h>
7141 +tcbhead_t* __get_cur_tcb(void) {
7142 +#if defined(__alpha__)
7143 + register void* cur asm("$0");
7144 + asm("call_pal 158" : "=r"(cur) ); /* PAL_rduniq = 158 */
7146 + register void* cur=0;
7147 +#if defined(__sparc__)
7148 + asm("mov %%g6,%0" : "=r"(cur) ); /* %g6 (res. system use) is used as thread pointer */
7149 +#elif defined(__s390__)
7150 + asm("ear %0,%%a0" : "=d"(cur) ); /* a0 (access register 0) is used as thread pointer */
7151 +#elif defined(__ia64__)
7152 + asm("mov %0 = r13" : "=r"(cur) ); /* r13 (tp) is used as thread pointer */
7153 +#elif defined(__x86_64__)
7155 + asm("movl %%fs:(0),%0" : "=r"(cur));
7157 + asm("movq %%fs:(0),%0" : "=r"(cur));
7159 +#elif defined(__i386__)
7160 + asm("movl %%gs:(0),%0" : "=r"(cur));
7162 +#endif /* __alpha__ */
7165 diff -urN -x .git dietlibc-0.33/lib/__get_elf_aux_value.c dietlibc/lib/__get_elf_aux_value.c
7166 --- dietlibc-0.33/lib/__get_elf_aux_value.c 1970-01-01 00:00:00.000000000 +0000
7167 +++ dietlibc/lib/__get_elf_aux_value.c 2015-01-01 12:14:43.481605561 +0000
7169 +#include "dietfeatures.h"
7171 +#ifdef WANT_ELFINFO
7172 +#include <stdlib.h>
7173 +#include "../dietelfinfo.h"
7175 +__diet_elf_addr_t const *__get_elf_aux_value(unsigned int tag)
7177 + extern __diet_elf_addr_t const * const __elfinfo;
7178 + __diet_elf_addr_t const *aux_ptr;
7180 + for (aux_ptr = __elfinfo; aux_ptr[0]!=AT_NULL; aux_ptr += 2)
7181 + if (aux_ptr[0]==tag)
7188 diff -urN -x .git dietlibc-0.33/lib/hcreate.c dietlibc/lib/hcreate.c
7189 --- dietlibc-0.33/lib/hcreate.c 1970-01-01 00:00:00.000000000 +0000
7190 +++ dietlibc/lib/hcreate.c 2015-01-01 12:14:43.484938895 +0000
7192 +#include <search.h>
7194 +static struct hsearch_data hd;
7196 +int hcreate(size_t count) {
7197 + return hcreate_r(count,&hd);
7200 +void hdestroy(void) {
7204 +ENTRY* hsearch(ENTRY item, ACTION action) {
7206 + if (hsearch_r(item,action,&x,&hd))
7210 diff -urN -x .git dietlibc-0.33/lib/hcreate_r.c dietlibc/lib/hcreate_r.c
7211 --- dietlibc-0.33/lib/hcreate_r.c 1970-01-01 00:00:00.000000000 +0000
7212 +++ dietlibc/lib/hcreate_r.c 2015-01-01 12:14:43.484938895 +0000
7214 +#define _GNU_SOURCE
7215 +#include <search.h>
7216 +#include <stdlib.h>
7217 +#include <unistd.h>
7219 +#include <sys/auxv.h>
7221 +int hcreate_r(size_t count, struct hsearch_data* htab) {
7224 + htab->table=calloc(count,sizeof(htab->table[0]));
7225 + if (htab->table) {
7226 + char* rnd=(char*)getauxval(AT_RANDOM);
7228 + memcpy(htab->key,rnd,16);
7230 + struct timeval tv;
7231 + struct timeval* x=(struct timeval*)htab->key;
7232 + if (getrandom(&htab->key,sizeof(htab->key),0) != sizeof(htab->key)) {
7233 + gettimeofday(&tv,NULL);
7234 + x->tv_sec += tv.tv_sec;
7235 + x->tv_usec += tv.tv_usec;
7239 + return htab->table ? 1 : 0;
7242 diff -urN -x .git dietlibc-0.33/lib/hdestroy_r.c dietlibc/lib/hdestroy_r.c
7243 --- dietlibc-0.33/lib/hdestroy_r.c 1970-01-01 00:00:00.000000000 +0000
7244 +++ dietlibc/lib/hdestroy_r.c 2015-01-01 12:14:43.484938895 +0000
7246 +#define _GNU_SOURCE
7247 +#include <search.h>
7248 +#include <stdlib.h>
7250 +static void freelist(struct bucket* b) {
7252 + struct bucket* o=b;
7258 +void hdestroy_r(struct hsearch_data* htab) {
7260 + for (i=0; i<htab->size; ++i) {
7261 + freelist(htab->table[i]);
7265 diff -urN -x .git dietlibc-0.33/lib/hsearch_r.c dietlibc/lib/hsearch_r.c
7266 --- dietlibc-0.33/lib/hsearch_r.c 1970-01-01 00:00:00.000000000 +0000
7267 +++ dietlibc/lib/hsearch_r.c 2015-01-01 12:14:43.484938895 +0000
7269 +#define _GNU_SOURCE
7270 +#include <search.h>
7271 +#include <string.h>
7273 +#include <stdlib.h>
7275 +static const size_t primes[] = {
7276 + 67, 127, 257, 521, 1031, 2053, 4099, 8191, 16381, 32771, 65537,
7277 + 131071, 262147, 524287, 1048583, 2097143 };
7279 +static const unsigned int nprimes = sizeof(primes)/sizeof(primes[0]);
7281 +int hsearch_r(ENTRY item, ACTION action, ENTRY** retval, struct hsearch_data* htab) {
7282 + uint64_t hv=siphash24(htab->key,(const unsigned char*)item.key,strlen(item.key));
7283 + struct bucket** b=&htab->table[hv%htab->size];
7285 + if ((*b)->hv==hv && !strcmp((*b)->e.key,item.key)) {
7287 + if (retval) *retval=&(*b)->e;
7292 + if (action==FIND) {
7296 + /* if we get this far, we are supposed to add the key */
7297 + if (htab -> size < primes[nprimes-1] && htab->filled+1 > htab->size) {
7298 + /* attempt to resize */
7300 + struct bucket** n;
7301 + for (i=0; i<nprimes; ++i)
7302 + if (htab->size < primes[i]) break;
7304 + n=calloc(i,sizeof(struct bucket*));
7305 + /* If the allocation failed, we can just limp on.
7306 + * Performance will be reduced but we'll live. */
7310 + for (j=0; j<htab->size; ++j) {
7311 + struct bucket* B=htab->table[j];
7313 + struct bucket* c=B;
7315 + unsigned int m=c->hv % i;
7320 + free(htab->table);
7323 + b=&htab->table[hv%htab->size];
7328 + *b=malloc(sizeof(struct bucket));
7329 + if (!*b) return 0;
7334 + if (retval) *retval=&(*b)->e;
7337 diff -urN -x .git dietlibc-0.33/lib/if_freenameindex.c dietlibc/lib/if_freenameindex.c
7338 --- dietlibc-0.33/lib/if_freenameindex.c 1970-01-01 00:00:00.000000000 +0000
7339 +++ dietlibc/lib/if_freenameindex.c 2015-01-01 12:14:43.484938895 +0000
7341 +#include <net/if.h>
7342 +#include <stdlib.h>
7344 +void if_freenameindex(struct if_nameindex* ptr) {
7347 diff -urN -x .git dietlibc-0.33/lib/makecontext.c dietlibc/lib/makecontext.c
7348 --- dietlibc-0.33/lib/makecontext.c 1970-01-01 00:00:00.000000000 +0000
7349 +++ dietlibc/lib/makecontext.c 2015-01-01 12:14:43.484938895 +0000
7351 +#include <ucontext.h>
7352 +#include <stdarg.h>
7354 +extern void __setcontext_trampoline();
7356 +void makecontext(ucontext_t* c, void (*func)(void), int argc, ...) {
7361 +#define PUSH(val) *++sp=(val);
7363 +#define PUSH(val) *--sp=(val);
7365 + /* we are called like this:
7367 + if (getcontext(&uctx_func1) == -1)
7368 + handle_error("getcontext");
7369 + uctx_func1.uc_stack.ss_sp = func1_stack;
7370 + uctx_func1.uc_stack.ss_size = sizeof(func1_stack);
7371 + uctx_func1.uc_link = &uctx_main;
7372 + makecontext(&uctx_func1, func1, 0);
7375 + /* first order of business: set up the stack */
7376 + /* the &-16 aligns it to 16 bytes */
7377 + sp=(size_t*)((size_t)(c->uc_stack.ss_sp + c->uc_stack.ss_size)&-16);
7378 + /* note that if the provided stack is to small, we will just crash in here */
7381 + /* if there are no args, we need to make sure there is space on the
7382 + * stack for the trampoline to pretend uc_link was passed as stack
7384 + if (!argc) PUSH(0);
7385 + /* we set up the context so we jump to it directly, and we leave
7386 + * __setcontext_trampoline as return address on the stack. */
7387 + /* __setcontext_trampoline needs to know the c->uc_link, so we put
7388 + * that into ebx, which is callee-saved */
7389 + c->uc_mcontext.ebx=(size_t)c->uc_link;
7391 + for (i=0; i<argc; ++i)
7392 + sp[i]=va_arg(v,size_t);
7393 + PUSH((size_t)__setcontext_trampoline);
7394 + c->uc_mcontext.esp=(size_t)sp;
7395 + c->uc_mcontext.eip=(size_t)func;
7396 +#elif defined __x86_64__
7397 + /* __setcontext_trampoline needs to know the c->uc_link, so we put
7398 + * that into ebx, which is callee-saved */
7399 + c->uc_mcontext.rbx=(size_t)c->uc_link;
7400 + for (i=0; i<argc; ++i) {
7402 + case 0: c->uc_mcontext.rdi=va_arg(v,size_t); break;
7403 + case 1: c->uc_mcontext.rsi=va_arg(v,size_t); break;
7404 + case 2: c->uc_mcontext.rdx=va_arg(v,size_t); break;
7405 + case 3: c->uc_mcontext.rcx=va_arg(v,size_t); break;
7406 + case 4: c->uc_mcontext.r8=va_arg(v,size_t); break;
7407 + case 5: c->uc_mcontext.r9=va_arg(v,size_t); break;
7408 + default: /* the rest goes on the stack */
7409 + PUSH(va_arg(v,size_t));
7412 + PUSH((size_t)__setcontext_trampoline);
7413 + c->uc_mcontext.rsp=(size_t)sp;
7414 + c->uc_mcontext.rip=(size_t)func;
7416 +#warning platform not supported yet in makecontext
7420 diff -urN -x .git dietlibc-0.33/lib/mbrlen.c dietlibc/lib/mbrlen.c
7421 --- dietlibc-0.33/lib/mbrlen.c 2008-12-10 20:00:59.000000000 +0000
7422 +++ dietlibc/lib/mbrlen.c 2015-01-01 12:14:43.484938895 +0000
7427 -static mbstate_t internal;
7429 size_t mbrlen(const char *s, size_t n, mbstate_t *ps) {
7430 static mbstate_t internal;
7431 return mbrtowc (NULL, s, n, ps ?: &internal);
7432 diff -urN -x .git dietlibc-0.33/lib/mmap64.c dietlibc/lib/mmap64.c
7433 --- dietlibc-0.33/lib/mmap64.c 2004-12-13 10:21:31.000000000 +0000
7434 +++ dietlibc/lib/mmap64.c 2015-01-01 12:14:43.484938895 +0000
7436 #include <syscalls.h>
7439 +#include "../dietpagesize.h"
7442 void*__mmap2(void*start,size_t length,int prot,int flags,int fd,off_t pgoffset);
7444 void*__libc_mmap64(void*addr,size_t len,int prot,int flags,int fd,off64_t offset);
7445 void*__libc_mmap64(void*addr,size_t len,int prot,int flags,int fd,off64_t offset) {
7446 - if (offset&(PAGE_SIZE-1)) {
7447 + if (offset&(__DIET_PAGE_SIZE)) {
7451 - return __mmap2(addr,len,prot,flags,fd,offset>>PAGE_SHIFT);
7452 + return __mmap2(addr,len,prot,flags,fd,offset>>__DIET_PAGE_SHIFT);
7455 void*mmap64(void*addr,size_t len,int prot,int flags,int fd,off64_t offset)
7456 diff -urN -x .git dietlibc-0.33/lib/mtx_destroy.c dietlibc/lib/mtx_destroy.c
7457 --- dietlibc-0.33/lib/mtx_destroy.c 1970-01-01 00:00:00.000000000 +0000
7458 +++ dietlibc/lib/mtx_destroy.c 2015-01-01 12:14:43.484938895 +0000
7460 +#include <threads.h>
7462 +void mtx_destroy(mtx_t* mutex) {
7463 + // no need to do anything
7466 diff -urN -x .git dietlibc-0.33/lib/mtx_init.c dietlibc/lib/mtx_init.c
7467 --- dietlibc-0.33/lib/mtx_init.c 1970-01-01 00:00:00.000000000 +0000
7468 +++ dietlibc/lib/mtx_init.c 2015-01-01 12:14:43.484938895 +0000
7470 +#include <threads.h>
7472 +int mtx_init(mtx_t* mutex, int type) {
7475 + return thrd_success;
7477 diff -urN -x .git dietlibc-0.33/lib/mtx_lock.c dietlibc/lib/mtx_lock.c
7478 --- dietlibc-0.33/lib/mtx_lock.c 1970-01-01 00:00:00.000000000 +0000
7479 +++ dietlibc/lib/mtx_lock.c 2015-01-01 12:14:43.484938895 +0000
7482 +#include <threads.h>
7483 +#include <sys/futex.h>
7486 +int mtx_lock(mtx_t* mutex) {
7487 + return mtx_timedlock(mutex,0);
7489 diff -urN -x .git dietlibc-0.33/lib/mtx_timedlock.c dietlibc/lib/mtx_timedlock.c
7490 --- dietlibc-0.33/lib/mtx_timedlock.c 1970-01-01 00:00:00.000000000 +0000
7491 +++ dietlibc/lib/mtx_timedlock.c 2015-01-01 12:14:43.484938895 +0000
7494 +#define _DIETLIBC_SOURCE
7495 +#include <threads.h>
7496 +#include <sys/futex.h>
7499 +int mtx_timedlock(mtx_t* mutex, const struct timespec* time_point) {
7501 + thrd_t me=thrd_current();
7503 + r=__mtx_trylock(mutex,&i);
7504 + if (r!=thrd_busy) return r;
7506 + r=futex(&mutex->lock,FUTEX_WAIT,i,time_point,0,0);
7508 + if (errno==EWOULDBLOCK) { r=0; break; } else
7509 + if (errno==ETIMEDOUT) return thrd_timedout; else
7510 + if (errno==EINTR) continue;
7515 + return thrd_error;
7517 diff -urN -x .git dietlibc-0.33/lib/mtx_trylock.c dietlibc/lib/mtx_trylock.c
7518 --- dietlibc-0.33/lib/mtx_trylock.c 1970-01-01 00:00:00.000000000 +0000
7519 +++ dietlibc/lib/mtx_trylock.c 2015-01-01 12:14:43.484938895 +0000
7522 +#define _DIETLIBC_SOURCE
7523 +#include <threads.h>
7524 +#include <sys/futex.h>
7527 +int __mtx_trylock(mtx_t* mutex,int* lockval) {
7529 + thrd_t me=thrd_current();
7530 + /* attempt to lock the mutex with an atomic instruction */
7531 + if ((i=__sync_val_compare_and_swap(&mutex->lock,0,1))==0) {
7533 + return thrd_success;
7535 + if ((mutex->type&mtx_recursive) && mutex->owner==me) {
7536 + if (__sync_add_and_fetch(&mutex->lock,1)>1000) {
7537 + __sync_add_and_fetch(&mutex->lock,-1);
7538 + return thrd_error;
7540 + return thrd_success;
7542 + if (lockval) *lockval=i;
7546 +int mtx_trylock(mtx_t* mutex) {
7547 + return __mtx_trylock(mutex,NULL);
7549 diff -urN -x .git dietlibc-0.33/lib/mtx_unlock.c dietlibc/lib/mtx_unlock.c
7550 --- dietlibc-0.33/lib/mtx_unlock.c 1970-01-01 00:00:00.000000000 +0000
7551 +++ dietlibc/lib/mtx_unlock.c 2015-01-01 12:14:43.484938895 +0000
7554 +#include <threads.h>
7555 +#include <sys/futex.h>
7558 +int mtx_unlock(mtx_t* mutex) {
7560 + thrd_t me=thrd_current();
7561 + if (mutex->lock==0) return thrd_error;
7562 + if ((mutex->type&mtx_recursive) && mutex->owner==me) {
7563 + if (__sync_add_and_fetch(&mutex->lock,-1)==0) {
7564 + // If we get here, the mutex was recursive, we unlocked it, and we
7565 + // were the last guy holding the lock. Wake waiters.
7566 + mutex->owner=0; // cosmetic; not really needed
7567 + futex(&mutex->lock,FUTEX_WAKE,1,0,0,0);
7569 + return thrd_success;
7571 + if (__sync_val_compare_and_swap(&mutex->lock,1,0)==1)
7572 + futex(&mutex->lock,FUTEX_WAKE,1,0,0,0);
7573 + return thrd_success;
7575 diff -urN -x .git dietlibc-0.33/lib/__nice.c dietlibc/lib/__nice.c
7576 --- dietlibc-0.33/lib/__nice.c 2005-01-21 18:25:10.000000000 +0000
7577 +++ dietlibc/lib/__nice.c 1970-01-01 00:00:00.000000000 +0000
7579 -#include "syscalls.h"
7580 -#include <sys/time.h>
7581 -#include <sys/resource.h>
7585 - return setpriority(PRIO_PROCESS,0,getpriority(PRIO_PROCESS,0)+i);
7588 diff -urN -x .git dietlibc-0.33/lib/nice.c dietlibc/lib/nice.c
7589 --- dietlibc-0.33/lib/nice.c 2012-01-15 18:43:18.000000000 +0000
7590 +++ dietlibc/lib/nice.c 2015-01-01 12:14:43.484938895 +0000
7594 + * nice() for uClibc
7596 + * Copyright (C) 2000-2004 by Erik Andersen <andersen@codepoet.org>
7597 + * Copyright (C) 2005 by Manuel Novoa III <mjn3@codepoet.org>
7599 + * GNU Library General Public License (LGPL) version 2 or later.
7603 -#include <unistd.h>
7604 +#include <limits.h>
7605 #include <sys/resource.h>
7607 -int nice(int incr) {
7611 - prio = getpriority(PRIO_PROCESS,0) + incr;
7612 - if (prio < PRIO_MIN) prio=PRIO_MIN;
7613 - if (prio >= PRIO_MAX) prio=PRIO_MAX-1;
7614 - if (setpriority (PRIO_PROCESS, 0, prio)==-1)
7617 - return getpriority(PRIO_PROCESS, 0);
7618 +static inline int int_add_no_wrap(int a, int b)
7622 + if ((b > 0) && (a > (INT_MAX - b)))
7624 + else if ((b < 0) && (a < (INT_MIN - b)))
7632 +static inline int __syscall_nice(int incr)
7637 + old_errno = errno;
7639 + old_priority = getpriority(PRIO_PROCESS, 0);
7640 + if ((old_priority == -1) && errno) {
7643 + __set_errno(old_errno);
7645 + if (setpriority(PRIO_PROCESS, 0, int_add_no_wrap(old_priority, incr))) {
7646 + __set_errno(EPERM); /* SUSv3 mandates EPERM for nice failure. */
7655 + if (__syscall_nice(incr)) {
7659 + return getpriority(PRIO_PROCESS, 0);
7661 diff -urN -x .git dietlibc-0.33/lib/opendir.c dietlibc/lib/opendir.c
7662 --- dietlibc-0.33/lib/opendir.c 2002-07-03 20:33:38.000000000 +0000
7663 +++ dietlibc/lib/opendir.c 2015-01-01 12:14:43.484938895 +0000
7668 +#include "../dietpagesize.h"
7670 DIR* opendir ( const char* name ) {
7671 int fd = open (name, O_RDONLY | O_DIRECTORY);
7675 if (fcntl (fd, F_SETFD, FD_CLOEXEC) < 0)
7677 - t = (DIR *) mmap (NULL, PAGE_SIZE, PROT_READ | PROT_WRITE,
7678 + t = (DIR *) mmap (NULL, __DIET_PAGE_SIZE, PROT_READ | PROT_WRITE,
7679 MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
7680 if (t == MAP_FAILED)
7682 diff -urN -x .git dietlibc-0.33/lib/readdir64.c dietlibc/lib/readdir64.c
7683 --- dietlibc-0.33/lib/readdir64.c 2004-03-02 21:27:19.000000000 +0000
7684 +++ dietlibc/lib/readdir64.c 2015-01-01 12:14:43.484938895 +0000
7687 #ifndef WANT_LARGEFILE_BACKCOMPAT
7688 struct dirent64* readdir64(DIR *d) {
7689 - if (!d->num || (d->cur += ((struct dirent64*)(d->buf+d->cur))->d_reclen)>=d->num) {
7690 - int res=getdents64(d->fd,(struct dirent64*)d->buf, sizeof (d->buf)-1);
7691 + struct linux_dirent64 *ld = d->num ? (struct linux_dirent64*)(d->buf+d->cur) : NULL;
7692 + if (!d->num || (d->cur += ld->d_reclen)>=d->num) {
7693 + int res=getdents64(d->fd,(struct linux_dirent64*)d->buf, __DIRSTREAM_BUF_SIZE-1);
7694 if (res<=0) return 0;
7695 - d->num=res; d->cur=0;
7696 + d->num=res; d->cur=0; d->is_64=1;
7698 + /* \todo: ensure that dirent64 and linux_dirent64 are compatible */
7699 return (struct dirent64*)(d->buf+d->cur);
7703 #ifdef __NR_getdents64
7704 static int trygetdents64=1;
7707 static struct dirent64 d64;
7708 #ifdef __NR_getdents64
7710 if (!trygetdents64) {
7712 - if (!d->num || (d->cur += ((struct dirent*)(d->buf+d->cur))->d_reclen)>=d->num) {
7713 - int res=getdents(d->fd,(struct dirent*)d->buf, sizeof (d->buf)-1);
7714 + struct linux_dirent *ld = d->num ? (struct linux_dirent*)(d->buf+d->cur) : NULL;
7715 + if (!d->num || (d->cur += ld->d_reclen)>=d->num) {
7716 + int res=getdents(d->fd,(struct linux_dirent*)d->buf, __DIRSTREAM_BUF_SIZE-1);
7717 if (res<=0) return 0;
7718 - d->num=res; d->cur=0;
7719 + d->num=res; d->cur=0;d->is_64=0;
7720 + ld=(struct linux_dirent*)(d->buf+d->cur);
7722 - o=(struct dirent*)(d->buf+d->cur);
7723 - d64.d_ino=o->d_ino;
7724 - d64.d_off=o->d_off;
7725 - d64.d_reclen=o->d_reclen;
7726 - strcpy(d64.d_name,o->d_name);
7727 + d64.d_ino=ld->d_ino;
7728 + d64.d_off=ld->d_off;
7729 + d64.d_reclen=ld->d_reclen;
7730 + strcpy(d64.d_name,ld->d_name);
7731 d64.d_type=0; /* is this correct? */
7733 #ifdef __NR_getdents64
7735 - if (!d->num || (d->cur += ((struct dirent64*)(d->buf+d->cur))->d_reclen)>=d->num) {
7736 - int res=getdents64(d->fd,(struct dirent64*)d->buf,sizeof (d->buf));
7738 + struct linux_dirent64 *ld = d->num ? (struct linux_dirent64*)(d->buf+d->cur) : NULL;
7739 + if (!d->num || (d->cur += ld->d_reclen)>=d->num) {
7740 + int res=getdents64(d->fd,(struct linux_dirent64*)d->buf,__DIRSTREAM_BUF_SIZE);
7742 if (errno==ENOSYS) {
7748 - d->num=res; d->cur=0;
7749 + d->num=res; d->cur=0; d->is_64=1;
7752 + /* \todo: ensure that dirent64 and linux_dirent64 are compatible */
7753 return (struct dirent64*)(d->buf+d->cur);
7756 diff -urN -x .git dietlibc-0.33/lib/readdir.c dietlibc/lib/readdir.c
7757 --- dietlibc-0.33/lib/readdir.c 2012-11-02 11:17:28.000000000 +0000
7758 +++ dietlibc/lib/readdir.c 2015-01-01 12:14:43.484938895 +0000
7760 +#define _POSIX_SOURCE
7761 #include "dietdirent.h"
7764 diff -urN -x .git dietlibc-0.33/lib/readdir_r.c dietlibc/lib/readdir_r.c
7765 --- dietlibc-0.33/lib/readdir_r.c 2012-10-30 19:54:17.000000000 +0000
7766 +++ dietlibc/lib/readdir_r.c 2015-01-01 12:14:43.484938895 +0000
7771 -struct linux_dirent {
7774 - uint16_t d_reclen;
7778 int readdir_r(DIR *d,struct dirent* entry, struct dirent** result) {
7779 - struct linux_dirent* ld;
7780 + struct linux_dirent* ld = d->num ? (struct linux_dirent*)(d->buf+d->cur) : NULL;
7782 - if (!d->num || (d->cur += ((struct dirent*)(d->buf+d->cur))->d_reclen)>=d->num) {
7783 - int res=getdents(d->fd,(struct dirent*)d->buf,sizeof (d->buf)-1);
7784 + if (!d->num || d->cur >= d->num || (d->cur += ld->d_reclen)>=d->num) {
7785 + int res=getdents(d->fd,(struct linux_dirent*)d->buf,__DIRSTREAM_BUF_SIZE-1);
7788 - d->num=res; d->cur=0;
7789 + d->num=res; d->cur=0; d->is_64=0;
7791 ld=(struct linux_dirent*)(d->buf+d->cur);
7792 if (ld->d_reclen < sizeof(struct linux_dirent))
7793 diff -urN -x .git dietlibc-0.33/lib/reallocarray.c dietlibc/lib/reallocarray.c
7794 --- dietlibc-0.33/lib/reallocarray.c 1970-01-01 00:00:00.000000000 +0000
7795 +++ dietlibc/lib/reallocarray.c 2015-01-01 12:14:43.484938895 +0000
7797 +#include <stdlib.h>
7798 +#include <endian.h>
7800 +#if __WORDSIZE == 64
7801 +typedef __uint128_t ulll;
7803 +typedef uint64_t ulll;
7806 +void* reallocarray(void* ptr, size_t nmemb, size_t size) {
7807 + /* produce a compile-time error if uintmax_t is not larger than size_t */
7808 + typedef char compile_time_assertion[(sizeof(ulll)>=sizeof(size_t)*2)-1];
7810 + ulll l=(ulll)nmemb * size;
7811 + if ((size_t)l != l) return 0; // overflow
7812 + return realloc(ptr,(size_t)l);
7814 diff -urN -x .git dietlibc-0.33/lib/seekdir.c dietlibc/lib/seekdir.c
7815 --- dietlibc-0.33/lib/seekdir.c 2006-05-29 16:30:53.000000000 +0000
7816 +++ dietlibc/lib/seekdir.c 2015-01-01 12:14:43.488272228 +0000
7821 -void seekdir(DIR *d,off_t offset) {
7822 +void seekdir(DIR *d,long offset) {
7823 if (lseek(d->fd,offset,SEEK_SET) != (off_t)-1) {
7825 - ((struct dirent *)(d->buf))->d_off = offset;
7827 + struct linux_dirent64 *ld = (void *)(d->buf + d->cur);
7828 + ld->d_off = offset;
7830 + struct linux_dirent *ld = (void *)(d->buf + d->cur);
7831 + ld->d_off = offset;
7835 diff -urN -x .git dietlibc-0.33/lib/sigandset.c dietlibc/lib/sigandset.c
7836 --- dietlibc-0.33/lib/sigandset.c 2004-12-17 19:14:49.000000000 +0000
7837 +++ dietlibc/lib/sigandset.c 2015-01-01 12:14:43.488272228 +0000
7839 int sigandset(sigset_t*set,const sigset_t*left,const sigset_t*right)
7841 set->sig[0]=left->sig[0]&right->sig[0];
7842 - if (_NSIG_WORDS>1) set->sig[1]=left->sig[1]&right->sig[1];
7843 - if (_NSIG_WORDS>2) {
7844 + if (_SIGSET_WORDS>1) set->sig[1]=left->sig[1]&right->sig[1];
7845 + if (_SIGSET_WORDS>2) {
7846 set->sig[2]=left->sig[2]&right->sig[2];
7847 set->sig[3]=left->sig[3]&right->sig[3];
7849 diff -urN -x .git dietlibc-0.33/lib/sigemptyset.c dietlibc/lib/sigemptyset.c
7850 --- dietlibc-0.33/lib/sigemptyset.c 2001-07-26 13:14:34.000000000 +0000
7851 +++ dietlibc/lib/sigemptyset.c 2015-01-01 12:14:43.488272228 +0000
7854 int sigemptyset(sigset_t *set) {
7856 - if (_NSIG_WORDS>1) set->sig[1]=0;
7857 - if (_NSIG_WORDS>2) {
7858 + if (_SIGSET_WORDS>1) set->sig[1]=0;
7859 + if (_SIGSET_WORDS>2) {
7863 diff -urN -x .git dietlibc-0.33/lib/sigfillset.c dietlibc/lib/sigfillset.c
7864 --- dietlibc-0.33/lib/sigfillset.c 2001-07-26 13:14:34.000000000 +0000
7865 +++ dietlibc/lib/sigfillset.c 2015-01-01 12:14:43.488272228 +0000
7868 int sigfillset(sigset_t *set) {
7869 set->sig[0]=(unsigned long)-1;
7870 - if (_NSIG_WORDS>1) set->sig[1]=(unsigned long)-1;
7871 - if (_NSIG_WORDS>2) {
7872 + if (_SIGSET_WORDS>1) set->sig[1]=(unsigned long)-1;
7873 + if (_SIGSET_WORDS>2) {
7874 set->sig[2]=(unsigned long)-1;
7875 set->sig[3]=(unsigned long)-1;
7877 diff -urN -x .git dietlibc-0.33/lib/sigisemptyset.c dietlibc/lib/sigisemptyset.c
7878 --- dietlibc-0.33/lib/sigisemptyset.c 2005-09-28 06:18:43.000000000 +0000
7879 +++ dietlibc/lib/sigisemptyset.c 2015-01-01 12:14:43.488272228 +0000
7884 - if (_NSIG_WORDS>1) ret|=set->sig[1];
7885 - if (_NSIG_WORDS>2) {
7886 + if (_SIGSET_WORDS>1) ret|=set->sig[1];
7887 + if (_SIGSET_WORDS>2) {
7891 diff -urN -x .git dietlibc-0.33/lib/signalfd.c dietlibc/lib/signalfd.c
7892 --- dietlibc-0.33/lib/signalfd.c 2008-08-30 13:59:28.000000000 +0000
7893 +++ dietlibc/lib/signalfd.c 2015-01-01 12:14:43.488272228 +0000
7897 #include <sys/signalfd.h>
7900 extern int __signalfd(int fd,const sigset_t* mask,size_t nsig);
7901 +extern int __signalfd4(int fd,const sigset_t* mask,size_t nsig, int flags);
7903 int signalfd(int fd,const sigset_t* mask,int flags) {
7904 - if (flags) { /* bizarre glibc bullshit */
7907 + int r=__signalfd4(fd,mask,_NSIG/8,flags);
7908 + if (r==-1 && errno==ENOSYS) {
7909 + r=__signalfd(fd,mask,NSIG/8);
7910 + if (r!=-1 && flags) {
7912 + x=fcntl(r,F_SETFD,flags);
7917 - return __signalfd(fd,mask,_NSIG/8);
7920 diff -urN -x .git dietlibc-0.33/lib/sigorset.c dietlibc/lib/sigorset.c
7921 --- dietlibc-0.33/lib/sigorset.c 2004-12-17 19:14:49.000000000 +0000
7922 +++ dietlibc/lib/sigorset.c 2015-01-01 12:14:43.488272228 +0000
7924 int sigorset(sigset_t*set,const sigset_t*left,const sigset_t*right)
7926 set->sig[0]=left->sig[0]|right->sig[0];
7927 - if (_NSIG_WORDS>1) set->sig[1]=left->sig[1]|right->sig[1];
7928 - if (_NSIG_WORDS>2) {
7929 + if (_SIGSET_WORDS>1) set->sig[1]=left->sig[1]|right->sig[1];
7930 + if (_SIGSET_WORDS>2) {
7931 set->sig[2]=left->sig[2]|right->sig[2];
7932 set->sig[3]=left->sig[3]|right->sig[3];
7934 diff -urN -x .git dietlibc-0.33/lib/siphash24.c dietlibc/lib/siphash24.c
7935 --- dietlibc-0.33/lib/siphash24.c 1970-01-01 00:00:00.000000000 +0000
7936 +++ dietlibc/lib/siphash24.c 2015-01-01 12:14:43.488272228 +0000
7938 +#include <search.h>
7940 +/* taken from https://github.com/floodyberry/siphash */
7942 +#define ROTL64(a,b) (((a)<<(b))|((a)>>(64-b)))
7945 +U8TO64_LE(const unsigned char *p) {
7946 + return *(const uint64_t *)p;
7950 +siphash24(const unsigned char key[16], const unsigned char *m, size_t len) {
7951 + uint64_t v0, v1, v2, v3;
7952 + uint64_t mi, k0, k1;
7956 + k0 = U8TO64_LE(key + 0);
7957 + k1 = U8TO64_LE(key + 8);
7958 + v0 = k0 ^ 0x736f6d6570736575ull;
7959 + v1 = k1 ^ 0x646f72616e646f6dull;
7960 + v2 = k0 ^ 0x6c7967656e657261ull;
7961 + v3 = k1 ^ 0x7465646279746573ull;
7963 + last7 = (uint64_t)(len & 0xff) << 56;
7965 +#define sipcompress() \
7966 + v0 += v1; v2 += v3; \
7967 + v1 = ROTL64(v1,13); v3 = ROTL64(v3,16); \
7968 + v1 ^= v0; v3 ^= v2; \
7969 + v0 = ROTL64(v0,32); \
7970 + v2 += v1; v0 += v3; \
7971 + v1 = ROTL64(v1,17); v3 = ROTL64(v3,21); \
7972 + v1 ^= v2; v3 ^= v0; \
7973 + v2 = ROTL64(v2,32);
7975 + for (i = 0, blocks = (len & ~7); i < blocks; i += 8) {
7976 + mi = U8TO64_LE(m + i);
7983 + switch (len - blocks) {
7984 + case 7: last7 |= (uint64_t)m[i + 6] << 48;
7985 + case 6: last7 |= (uint64_t)m[i + 5] << 40;
7986 + case 5: last7 |= (uint64_t)m[i + 4] << 32;
7987 + case 4: last7 |= (uint64_t)m[i + 3] << 24;
7988 + case 3: last7 |= (uint64_t)m[i + 2] << 16;
7989 + case 2: last7 |= (uint64_t)m[i + 1] << 8;
7990 + case 1: last7 |= (uint64_t)m[i + 0] ;
8003 + return v0 ^ v1 ^ v2 ^ v3;
8005 diff -urN -x .git dietlibc-0.33/lib/stackgap.c dietlibc/lib/stackgap.c
8006 --- dietlibc-0.33/lib/stackgap.c 2012-01-24 18:24:26.000000000 +0000
8007 +++ dietlibc/lib/stackgap.c 2015-01-01 12:14:43.488272228 +0000
8011 #include "dietfeatures.h"
8012 +#include <sys/auxv.h>
8013 +#include "dietelfinfo.h"
8020 #ifdef WANT_GNU_STARTUP_BLOAT
8021 char* program_invocation_name;
8022 char* program_invocation_short_name;
8026 +void const * __vdso;
8028 extern int main(int argc,char* argv[],char* envp[]);
8032 static void findtlsdata(long* auxvec) {
8033 #if (__WORDSIZE == 64)
8035 + Elf64_Phdr const * x=0;
8038 + Elf32_Phdr const * x=0;
8041 +#ifndef WANT_ELFINFO
8043 if (auxvec[0]==3) { /* AT_PHDR */
8048 } /* if we don't find the entry, the kernel let us down */
8051 + __diet_elf_addr_t const *x_addr = __get_elf_aux_value(AT_PHDR);
8052 + __diet_elf_addr_t const *n_addr = __get_elf_aux_value(AT_PHNUM);
8056 + x = (__typeof__(x)) *x_addr;
8061 if (!x || !n) return; /* a kernel this old does not support thread local storage anyway */
8063 if (x[i].p_type==PT_TLS) {
8064 __tdataptr=(void*)x[i].p_vaddr;
8065 __tdatasize=x[i].p_filesz;
8066 __tmemsize=x[i].p_memsz;
8067 + if (__tmemsize&15)
8068 + __tmemsize=(__tmemsize+15)&~15;
8071 /* if there is no PT_TLS section, there is no thread-local data, and
8072 @@ -113,42 +135,61 @@
8074 #elif defined(__alpha__) || defined(__s390__)
8075 __builtin_set_thread_pointer(mainthread);
8076 -#elif defined(__ia64__) || defined(__powerpc__)
8077 - register tcbhead_t* __thread_self __asm__("r13");
8078 - __thread_self=mainthread;
8079 -#elif defined(__sparc__)
8080 - register tcbhead_t* __thread_self __asm("%g7");
8081 +#elif defined(__arm__)
8082 + __arm_set_tls(mainthread);
8083 +#elif defined(__ABI_TLS_REGISTER)
8084 + register tcbhead_t* __thread_self __asm__(__ABI_TLS_REGISTER);
8085 __thread_self=mainthread;
8086 + __asm__ __volatile__("" : : "r"(__thread_self) : "memory");
8088 -#warning "no idea how to enable TLS on this platform, edit lib/stackgap.c"
8089 +#error "no idea how to enable TLS on this platform, edit lib/stackgap.c"
8094 -static void* find_in_auxvec(long* x,long what) {
8095 +static void const * find_in_auxvec(long* x,long what) {
8096 +#ifndef WANT_ELFINFO
8104 + __diet_elf_addr_t const *a = __get_elf_aux_value(what);
8106 + return a ? (void *)*a : NULL;
8110 +#ifndef WANT_ELFINFO
8111 +static long* _auxvec;
8113 +#define _auxvec NULL
8116 +unsigned long getauxval(unsigned long type) {
8117 + return (long)find_in_auxvec(_auxvec,type);
8120 int stackgap(int argc,char* argv[],char* envp[]);
8121 int stackgap(int argc,char* argv[],char* envp[]) {
8122 - long* auxvec=(long*)envp;
8123 #if defined(WANT_STACKGAP) || defined(WANT_SSP) || defined(WANT_TLS)
8125 + char const * rand;
8127 + long* auxvec=(long*)envp;
8128 +#ifndef WANT_ELFINFO
8129 while (*auxvec) ++auxvec; ++auxvec; /* skip envp to get to auxvec */
8132 #ifdef WANT_STACKGAP
8134 + volatile char* gap;
8136 #if defined(WANT_STACKGAP) || defined(WANT_SSP)
8137 - volatile char* gap;
8139 rand=find_in_auxvec(auxvec,25);
8142 int fd=open("/dev/urandom",O_RDONLY);
8146 memcpy(tlsdata,__tdataptr,__tdatasize);
8147 memset(tlsdata+__tdatasize,0,__tmemsize-__tdatasize);
8148 __setup_tls(__tcb_mainthread=(tcbhead_t*)(tlsdata+__tmemsize));
8149 + __tcb_mainthread->sysinfo=(uintptr_t)find_in_auxvec(auxvec,32);
8150 #elif defined(WANT_SSP)
8151 tlsdata=alloca(sizeof(tcbhead_t));
8152 __setup_tls(__tcb_mainthread=(tcbhead_t*)(tlsdata));
8153 diff -urN -x .git dietlibc-0.33/lib/stack_smash_handler2.c dietlibc/lib/stack_smash_handler2.c
8154 --- dietlibc-0.33/lib/stack_smash_handler2.c 2006-04-04 05:35:14.000000000 +0000
8155 +++ dietlibc/lib/stack_smash_handler2.c 2015-01-01 12:14:43.488272228 +0000
8157 * diagnostics. No more. :-( */
8158 void __stack_chk_fail(void) {
8159 __write2("smashed stack detected, program terminated.\n");
8162 + /* trigger a segfault which can be inspected within a debugger (inclusive
8163 + * stack-trace). 'abort(3)' at this place would be too heavy weighted.
8165 + * TODO: limit this to systems which are known to have an MMU (resp. is
8166 + * dietlibc with stack-protector used on systems without an MMU?)
8168 + *(char volatile *)0 = 0;
8170 +#if defined(__GNUC__) && ((((__GNUC__) << 8) | (__GNUC_MINOR__)) >= 0x405)
8171 + __builtin_unreachable();
8175 diff -urN -x .git dietlibc-0.33/lib/stpcpy.c dietlibc/lib/stpcpy.c
8176 --- dietlibc-0.33/lib/stpcpy.c 1970-01-01 00:00:00.000000000 +0000
8177 +++ dietlibc/lib/stpcpy.c 2015-01-01 12:14:43.488272228 +0000
8179 +#include <string.h>
8181 +char * stpcpy (char *dst, const char *src) {
8182 + while ((*dst++ = *src++));
8185 diff -urN -x .git dietlibc-0.33/lib/swapcontext.c dietlibc/lib/swapcontext.c
8186 --- dietlibc-0.33/lib/swapcontext.c 1970-01-01 00:00:00.000000000 +0000
8187 +++ dietlibc/lib/swapcontext.c 2015-01-01 12:14:43.488272228 +0000
8189 +#include <ucontext.h>
8192 +int swapcontext(ucontext_t* o,const ucontext_t* n) {
8193 + volatile int once=0;
8194 + if (getcontext(o)==-1) return -1;
8197 + return setcontext(n);
8201 diff -urN -x .git dietlibc-0.33/lib/tcsetattr.c dietlibc/lib/tcsetattr.c
8202 --- dietlibc-0.33/lib/tcsetattr.c 2002-01-11 18:06:53.000000000 +0000
8203 +++ dietlibc/lib/tcsetattr.c 2015-01-01 12:14:43.488272228 +0000
8206 #include "dietfeatures.h"
8208 -#if !defined(__powerpc__) && !defined(__sparc__) && !defined(__alpha__) && !defined(__hppa__)
8209 -#if TCSANOW==0 && TCSADRAIN==1 && TCSAFLUSH==2 && TCSETSW-TCSETS==1 && TCSETSF-TCSETS==2
8214 int tcsetattr ( int fildes, int optional_actions, struct termios* termios_p )
8218 - if ( (unsigned int)optional_actions < 3u )
8219 - return ioctl ( fildes, TCSETS+optional_actions, termios_p );
8226 switch ( optional_actions ) {
8228 return ioctl ( fildes, TCSETS , termios_p );
8236 diff -urN -x .git dietlibc-0.33/lib/telldir.c dietlibc/lib/telldir.c
8237 --- dietlibc-0.33/lib/telldir.c 2006-05-29 16:30:53.000000000 +0000
8238 +++ dietlibc/lib/telldir.c 2015-01-01 12:14:43.488272228 +0000
8243 -off_t telldir(DIR *d) {
8245 - if (lseek(d->fd,0,SEEK_CUR))
8246 - result=((struct dirent*)(d->buf+d->cur))->d_off;
8247 +long telldir(DIR *d) {
8249 + if (lseek(d->fd,0,SEEK_CUR)) {
8251 + struct linux_dirent64 *ld = (void *)(d->buf + d->cur);
8254 + struct linux_dirent *ld = (void *)(d->buf + d->cur);
8260 diff -urN -x .git dietlibc-0.33/lib/thrd_create.c dietlibc/lib/thrd_create.c
8261 --- dietlibc-0.33/lib/thrd_create.c 1970-01-01 00:00:00.000000000 +0000
8262 +++ dietlibc/lib/thrd_create.c 2015-01-01 12:14:43.488272228 +0000
8264 +#define _LINUX_SOURCE
8265 +#include <unistd.h>
8266 +#include <threads.h>
8267 +#include <sys/mman.h>
8269 +#define _GNU_SOURCE
8271 +#include "dietfeatures.h"
8272 +#include <sys/tls.h>
8275 +extern thrd_t _thrd_root;
8276 +extern size_t _thrd_stacksize;
8279 +extern size_t __tdatasize, __tmemsize;
8280 +extern void* __tdataptr;
8281 +extern tcbhead_t* __tcb_mainthread;
8283 +static const size_t __tmemsize=0,__tdatasize=0;
8286 +static int launch(void* p) {
8288 + thrd_exit(self->func(self->arg));
8292 +int thrd_create(thrd_t *thr, thrd_start_t func, void *arg) {
8293 + size_t stacksize=_thrd_stacksize; // capture value to prevent asynchronous changes to break us
8294 + char* stack=mmap(0,stacksize+4096+__tmemsize+sizeof(tcbhead_t)+sizeof(**thr),PROT_NONE,MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK|MAP_GROWSDOWN,-1,0);
8299 + if (stack==MAP_FAILED) return thrd_nomem;
8301 + if (mprotect(stack+4096,stacksize+__tmemsize+sizeof(tcbhead_t)+sizeof(**thr),PROT_READ|PROT_WRITE)) {
8302 + munmap(stack,stacksize+4096+__tmemsize+sizeof(tcbhead_t)+sizeof(**thr));
8303 + return thrd_error;
8305 + tcb=(tcbhead_t*)(stack+stacksize+4096+__tmemsize);
8308 + t=(thrd_t)(tcb+1);
8310 + tcb->multiple_threads=1;
8312 + tcb->sysinfo=__tcb_mainthread->sysinfo;
8313 + tcb->stack_guard=__tcb_mainthread->stack_guard ^ gettid() ^ (uintptr_t)t;
8314 + __tcb_mainthread->multiple_threads=1;
8316 + t->memstart=stack;
8317 + t->memsize=stacksize+4096+__tmemsize;
8325 + memcpy(stack+stacksize+4096,__tdataptr,__tdatasize);
8326 + memset(stack+stacksize+4096+__tdatasize,0,__tmemsize-__tdatasize);
8329 + t->tid=clone(launch,stack+4096+stacksize,CLONE_FILES|CLONE_FS|CLONE_IO|CLONE_PARENT|CLONE_SIGHAND|CLONE_SYSVSEM|CLONE_THREAD|CLONE_VM|CLONE_SETTLS|CLONE_PARENT_SETTID,t,&t->tid,stack+stacksize+4096+__tmemsize);
8331 + munmap(stack,stacksize+4096+__tmemsize+sizeof(tcbhead_t)+sizeof(**thr));
8332 + return thrd_error;
8335 + return thrd_success;
8337 diff -urN -x .git dietlibc-0.33/lib/thrd_current.c dietlibc/lib/thrd_current.c
8338 --- dietlibc-0.33/lib/thrd_current.c 1970-01-01 00:00:00.000000000 +0000
8339 +++ dietlibc/lib/thrd_current.c 2015-01-01 12:14:43.488272228 +0000
8341 +#include <sys/tls.h>
8342 +#include <threads.h>
8344 +thrd_t thrd_current(void) {
8345 + tcbhead_t* x=__get_cur_tcb();
8346 + if (x->multiple_threads==0) return NULL;
8347 + return (thrd_t)(x+1);
8349 diff -urN -x .git dietlibc-0.33/lib/thrd_detach.c dietlibc/lib/thrd_detach.c
8350 --- dietlibc-0.33/lib/thrd_detach.c 1970-01-01 00:00:00.000000000 +0000
8351 +++ dietlibc/lib/thrd_detach.c 2015-01-01 12:14:43.488272228 +0000
8353 +#include <threads.h>
8354 +#include <sys/tls.h>
8355 +#include <sys/mman.h>
8357 +int thrd_detach(thrd_t thr) {
8358 + int flags=thr->flags;
8360 + if (flags&4) return thrd_error;
8362 + munmap(thr->memstart+thr->memsize,sizeof(tcbhead_t)+sizeof(*thr));
8363 + return thrd_success;
8365 + if (flags&1) return thrd_success;
8366 + flags=__sync_val_compare_and_swap(&thr->flags,flags,flags|1);
8370 diff -urN -x .git dietlibc-0.33/lib/thrd_exit.c dietlibc/lib/thrd_exit.c
8371 --- dietlibc-0.33/lib/thrd_exit.c 1970-01-01 00:00:00.000000000 +0000
8372 +++ dietlibc/lib/thrd_exit.c 2015-01-01 12:14:43.488272228 +0000
8375 +#define _LINUX_SOURCE
8376 +#include <threads.h>
8377 +#include <unistd.h>
8378 +#include <sys/futex.h>
8379 +#include <sys/tls.h>
8380 +#include <stdlib.h>
8383 +extern void __munmap_and_exit(void* map,size_t len) __attribute__((noreturn));
8385 +thread_local tss_t tss_dtor_list;
8387 +void thrd_exit(int res) {
8388 + thrd_t t=thrd_current();
8393 + while (tss_dtor_list) {
8394 + tss_t cur=tss_dtor_list;
8395 + tss_dtor_list=tss_dtor_list->next;
8396 + if (cur->dtor) cur->dtor(cur);
8398 + if (!t) exit(res); // moron user called us when no threads are running
8400 + if ((flags=__sync_fetch_and_or(&t->flags,4))&4) return; // shouldn't be possible, but the tear-down-bit was already set
8401 + if (t->join_futex) { // somebody is waiting; send him a message
8402 + t->join_wait_futex=0;
8403 + if (futex(&t->join_futex,FUTEX_WAKE,1,0,0,0)==1) { // wake the guy waiting for us
8404 + // We woke somebody up.
8405 + // Give him time to read our exit code.
8408 + r=futex(&t->join_wait_futex,FUTEX_WAIT,0,0,0,0);
8409 + } while (r==EINTR);
8411 + flags|=1; // mark as detached
8416 + // We are detached or somebody already thrd_join'ed us.
8417 + // We can die in piece and free all our resources
8418 + len += sizeof(tcbhead_t)+sizeof(*t);
8420 + // Tell thrd_join that we are dead and cleaned up our stack and it
8421 + // should clean up the rest when it's done.
8422 + __sync_fetch_and_or(&t->flags,2);
8423 + len&=~4095; // round down to nearest page
8424 + t->arg=t->memstart+len;
8425 + t->memsize=t->memsize+sizeof(tcbhead_t)+sizeof(*t)-len;
8427 + /* Problem: we need to unmap the stack and call exit, but we can't
8428 + * touch the stack in between. Unfortunately, calling exit touches the
8429 + * stack. Returning from the munmap syscall also touches the stack. So
8430 + * this needs to be done in assembly language. */
8431 + __munmap_and_exit(t->memstart,len);
8433 diff -urN -x .git dietlibc-0.33/lib/thrd_join.c dietlibc/lib/thrd_join.c
8434 --- dietlibc-0.33/lib/thrd_join.c 1970-01-01 00:00:00.000000000 +0000
8435 +++ dietlibc/lib/thrd_join.c 2015-01-01 12:14:43.488272228 +0000
8438 +#include <threads.h>
8439 +#include <sys/futex.h>
8440 +#include <sys/mman.h>
8441 +#include <sys/tls.h>
8444 +int thrd_join(thrd_t thr, int* res) {
8445 + int flags=thr->flags;
8447 + if ((flags&2)==0) {
8449 + // thread is detached or in the process of being cleaned up, refuse join
8450 + return thrd_error;
8451 + if (!__sync_bool_compare_and_swap(&thr->join_futex,0,1))
8452 + // somebody is already calling thrd_join, refuse join
8453 + return thrd_error;
8455 + r=futex(&thr->join_futex,FUTEX_WAIT,1,0,0,0);
8456 + } while (r==-1 && errno==EINTR);
8457 + if (res) *res=thr->res;
8458 + thr->join_wait_futex=1;
8459 + futex(&thr->join_wait_futex,FUTEX_WAKE,1,0,0,0);
8461 + if (res) *res=thr->res;
8462 + munmap(thr->arg,thr->memsize);
8464 + return thrd_success;
8467 diff -urN -x .git dietlibc-0.33/lib/thrd_root.c dietlibc/lib/thrd_root.c
8468 --- dietlibc-0.33/lib/thrd_root.c 1970-01-01 00:00:00.000000000 +0000
8469 +++ dietlibc/lib/thrd_root.c 2015-01-01 12:14:43.488272228 +0000
8471 +#include <threads.h>
8474 +size_t _thrd_stacksize=16*1024;
8475 diff -urN -x .git dietlibc-0.33/lib/tss_create.c dietlibc/lib/tss_create.c
8476 --- dietlibc-0.33/lib/tss_create.c 1970-01-01 00:00:00.000000000 +0000
8477 +++ dietlibc/lib/tss_create.c 2015-01-01 12:14:43.488272228 +0000
8479 +#include <stdlib.h>
8480 +#include <threads.h>
8482 +extern thread_local tss_t tss_dtor_list;
8484 +int tss_create(tss_t* tss_id, tss_dtor_t destructor) {
8485 + *tss_id=malloc(sizeof(**tss_id));
8486 + if (!*tss_id) return thrd_nomem;
8487 + (*tss_id)->dtor=destructor;
8488 + (*tss_id)->next=tss_dtor_list;
8489 + (*tss_id)->data=0;
8490 + tss_dtor_list=*tss_id;
8491 + return thrd_success;
8493 diff -urN -x .git dietlibc-0.33/lib/tss_delete.c dietlibc/lib/tss_delete.c
8494 --- dietlibc-0.33/lib/tss_delete.c 1970-01-01 00:00:00.000000000 +0000
8495 +++ dietlibc/lib/tss_delete.c 2015-01-01 12:14:43.488272228 +0000
8497 +#include <threads.h>
8499 +extern thread_local tss_t tss_dtor_list;
8501 +void tss_delete(tss_t tss_id) {
8503 + for (cur=&tss_dtor_list; *cur; cur=&((*cur)->next)) {
8505 + *cur=tss_id->next;
8511 diff -urN -x .git dietlibc-0.33/lib/tss_get.c dietlibc/lib/tss_get.c
8512 --- dietlibc-0.33/lib/tss_get.c 1970-01-01 00:00:00.000000000 +0000
8513 +++ dietlibc/lib/tss_get.c 2015-01-01 12:14:43.488272228 +0000
8515 +#include <threads.h>
8517 +void* tss_get(tss_t tss_id) {
8518 + return tss_id->data;
8520 diff -urN -x .git dietlibc-0.33/lib/tss_set.c dietlibc/lib/tss_set.c
8521 --- dietlibc-0.33/lib/tss_set.c 1970-01-01 00:00:00.000000000 +0000
8522 +++ dietlibc/lib/tss_set.c 2015-01-01 12:14:43.488272228 +0000
8524 +#include <threads.h>
8526 +int tss_set(tss_t tss_id, void* val) {
8528 + return thrd_success;
8530 diff -urN -x .git dietlibc-0.33/lib/__utime.c dietlibc/lib/__utime.c
8531 --- dietlibc-0.33/lib/__utime.c 2011-03-03 18:40:05.000000000 +0000
8532 +++ dietlibc/lib/__utime.c 2015-01-01 12:14:43.481605561 +0000
8535 #include <syscalls.h>
8536 +#define _BSD_SOURCE
8538 +#include <sys/time.h>
8541 +#define _BSD_SOURCE
8543 +#include <sys/time.h>
8545 int utime(const char *filename, const struct utimbuf *times)
8548 diff -urN -x .git dietlibc-0.33/lib/__v_printf.c dietlibc/lib/__v_printf.c
8549 --- dietlibc-0.33/lib/__v_printf.c 2008-05-06 17:18:34.000000000 +0000
8550 +++ dietlibc/lib/__v_printf.c 2015-01-01 12:14:43.481605561 +0000
8556 #include "dietstdio.h"
8557 #include "dietwarning.h"
8559 @@ -346,45 +347,49 @@
8560 #ifdef WANT_FLOATING_POINT_IN_PRINTF
8561 /* print a floating point value */
8568 + int flags=(((ch&0x5f)=='G') ? 0x01 : 0x00) | ((ch&0x20) ? 0x00 : 0x02);
8569 double d=va_arg(arg_ptr,double);
8571 if (width==0) width=1;
8572 if (!flag_dot) preci=6;
8573 if (flag_sign || d < +0.0) flag_in_sign=1;
8575 - sz=__dtostr(d,s,sizeof(buf)-1,width,preci,g);
8576 + sz=__dtostr(d,s,sizeof(buf)-1,width,preci,flags);
8580 - if ((tmp=strchr(s,'.'))) {
8581 - if (preci || flag_hash) ++tmp;
8582 - while (preci>0 && *++tmp) --preci;
8584 - } else if (flag_hash) {
8587 + if (!isnan(d) && !isinf(d)) { /* skip NaN + INF values */
8590 + if ((tmp=strchr(s,'.'))) {
8591 + if (preci || flag_hash) ++tmp;
8592 + while (preci>0 && *++tmp) --preci;
8594 + } else if (flag_hash) {
8602 - char *tmp,*tmp1; /* boy, is _this_ ugly! */
8603 - if ((tmp=strchr(s,'.'))) {
8604 - tmp1=strchr(tmp,'e');
8605 - while (*tmp) ++tmp;
8606 - if (tmp1) tmp=tmp1;
8607 - while (*--tmp=='0') ;
8608 - if (*tmp!='.') ++tmp;
8610 - if (tmp1) strcpy(tmp,tmp1);
8611 + if ((flags&0x01)) {
8612 + char *tmp,*tmp1; /* boy, is _this_ ugly! */
8613 + if ((tmp=strchr(s,'.'))) {
8614 + tmp1=strchr(tmp,'e');
8615 + while (*tmp) ++tmp;
8616 + if (tmp1) tmp=tmp1;
8617 + while (*--tmp=='0') ;
8618 + if (*tmp!='.') ++tmp;
8620 + if (tmp1) strcpy(tmp,tmp1);
8625 - if ((flag_sign || flag_space) && d>=0) {
8626 - *(--s)=(flag_sign)?'+':' ';
8628 + if ((flag_sign || flag_space) && d>=0) {
8629 + *(--s)=(flag_sign)?'+':' ';
8635 diff -urN -x .git dietlibc-0.33/libcompat/rcmd.c dietlibc/libcompat/rcmd.c
8636 --- dietlibc-0.33/libcompat/rcmd.c 2005-05-08 15:33:39.000000000 +0000
8637 +++ dietlibc/libcompat/rcmd.c 2015-01-01 12:14:43.491605562 +0000
8639 const char *remuser, const char *cmd, int *fd2p);
8640 int rcmd(char **ahost, int inport, const char *locuser,
8641 const char *remuser, const char *cmd, int *fd2p) {
8648 __write2("for security reasons, rcmd is not supported by the diet libc.\n");
8651 diff -urN -x .git dietlibc-0.33/libcompat/stpcpy.c dietlibc/libcompat/stpcpy.c
8652 --- dietlibc-0.33/libcompat/stpcpy.c 2002-05-03 21:22:06.000000000 +0000
8653 +++ dietlibc/libcompat/stpcpy.c 1970-01-01 00:00:00.000000000 +0000
8655 -#include <string.h>
8657 -char * stpcpy (char *dst, const char *src) {
8658 - while ((*dst++ = *src++));
8661 diff -urN -x .git dietlibc-0.33/libcompat/syscall.S dietlibc/libcompat/syscall.S
8662 --- dietlibc-0.33/libcompat/syscall.S 2006-05-29 16:30:53.000000000 +0000
8663 +++ dietlibc/libcompat/syscall.S 2015-01-01 12:14:43.491605562 +0000
8664 @@ -130,6 +130,13 @@
8668 - /* arch not implemented yet */
8669 +#include <endian.h>
8671 +#if (__WORDSIZE == 64)
8672 + .quad __syscall_2_not_implemented_for_this_arch
8674 + .long __syscall_2_not_implemented_for_this_arch
8678 .size syscall, . - syscall
8679 diff -urN -x .git dietlibc-0.33/libcruft/bindtextdomain.c dietlibc/libcruft/bindtextdomain.c
8680 --- dietlibc-0.33/libcruft/bindtextdomain.c 2003-11-14 15:16:51.000000000 +0000
8681 +++ dietlibc/libcruft/bindtextdomain.c 2015-01-01 12:14:43.491605562 +0000
8685 char* bindtextdomain(const char* domainname,const char* dirname) {
8688 if (!(dir=strdup(dirname))) return 0;
8690 diff -urN -x .git dietlibc-0.33/libcruft/dcgettext.c dietlibc/libcruft/dcgettext.c
8691 --- dietlibc-0.33/libcruft/dcgettext.c 2003-11-04 18:26:52.000000000 +0000
8692 +++ dietlibc/libcruft/dcgettext.c 2015-01-01 12:14:43.491605562 +0000
8694 #include <libintl.h>
8696 char* dcgettext(const char *domainname, const char *msgid, int category) {
8699 return (char*)msgid;
8701 diff -urN -x .git dietlibc-0.33/libcruft/dgettext.c dietlibc/libcruft/dgettext.c
8702 --- dietlibc-0.33/libcruft/dgettext.c 2003-11-04 18:26:52.000000000 +0000
8703 +++ dietlibc/libcruft/dgettext.c 2015-01-01 12:14:43.491605562 +0000
8705 #include <libintl.h>
8708 -char* dgettext(const char* domainname, const char* x) { return (char*)x; }
8709 +char* dgettext(const char* domainname, const char* x) { (void)domainname; return (char*)x; }
8710 diff -urN -x .git dietlibc-0.33/libcruft/getpagesize.c dietlibc/libcruft/getpagesize.c
8711 --- dietlibc-0.33/libcruft/getpagesize.c 2009-07-01 00:27:26.000000000 +0000
8712 +++ dietlibc/libcruft/getpagesize.c 2015-01-01 12:14:43.491605562 +0000
8714 #include <sys/types.h>
8715 #include <sys/ipc.h>
8716 #include <sys/shm.h>
8718 -#include <stdlib.h>
8721 -#define PAGE_SIZE 4096
8723 +#include "../dietelfinfo.h"
8724 +#include "../dietpagesize.h"
8726 -size_t __libc_getpagesize(void);
8727 size_t __libc_getpagesize(void) {
8728 - long* x=(long*)environ;
8730 - while (*x) ++x; ++x; /* skip envp to get to auxvec */
8735 +#ifdef WANT_DYN_PAGESIZE
8736 + static size_t pgsz;
8738 + if (__unlikely(pgsz==0)) {
8739 + __diet_elf_addr_t const *v = __get_elf_aux_value(AT_PAGESZ);
8740 + pgsz = *v; /* causes segfault when 'v==NULL' */
8746 + return __DIET_PAGE_SIZE_PREDEF;
8750 size_t getpagesize(void) __attribute__((weak,alias("__libc_getpagesize")));
8752 diff -urN -x .git dietlibc-0.33/libcruft/mkstemp.c dietlibc/libcruft/mkstemp.c
8753 --- dietlibc-0.33/libcruft/mkstemp.c 2001-08-16 18:44:17.000000000 +0000
8754 +++ dietlibc/libcruft/mkstemp.c 2015-01-01 12:14:43.494938894 +0000
8756 +#define _FILE_OFFSET_BITS 64
8760 diff -urN -x .git dietlibc-0.33/libcruft/res_mkquery.c dietlibc/libcruft/res_mkquery.c
8761 --- dietlibc-0.33/libcruft/res_mkquery.c 2007-03-09 13:42:12.000000000 +0000
8762 +++ dietlibc/libcruft/res_mkquery.c 2015-01-01 12:14:43.494938894 +0000
8764 unsigned char packet[512];
8771 memcpy(packet,dnspacket,12);
8776 if ((_res.options&RES_RECURSE)==0) packet[2]=0;
8777 + packet[2] |= (op&7)<<3;
8780 const char* y,* tmp;
8781 diff -urN -x .git dietlibc-0.33/libcruft/sysconf.c dietlibc/libcruft/sysconf.c
8782 --- dietlibc-0.33/libcruft/sysconf.c 2012-01-24 18:24:27.000000000 +0000
8783 +++ dietlibc/libcruft/sysconf.c 2015-01-01 12:14:43.494938894 +0000
8788 +#include "dietelfinfo.h"
8789 +#include "dietpagesize.h"
8791 extern int __sc_nr_cpus();
8793 static long physpages() {
8795 return limit.rlim_cur;
8798 +#ifdef WANT_ELFINFO
8800 + __diet_elf_addr_t const *v = __get_elf_aux_value(AT_CLKTCK);
8813 -#if ( defined(__alpha__) || defined(__sparc__) )
8818 + return __libc_getpagesize();
8820 case _SC_PHYS_PAGES:
8822 diff -urN -x .git dietlibc-0.33/libcruft/tmpnam.c dietlibc/libcruft/tmpnam.c
8823 --- dietlibc-0.33/libcruft/tmpnam.c 2002-02-23 22:18:42.000000000 +0000
8824 +++ dietlibc/libcruft/tmpnam.c 2015-01-01 12:14:43.494938894 +0000
8826 if (s) tmp=s; else tmp=buf;
8827 strcpy(tmp,"/tmp/temp_");
8833 for (j=0; j<8; ++j) {
8838 - if (lstat(tmp,&s)==-1 && errno==ENOENT) break;
8839 + if (lstat(tmp,&ss)==-1 && errno==ENOENT) break;
8843 diff -urN -x .git dietlibc-0.33/libm/ceil.c dietlibc/libm/ceil.c
8844 --- dietlibc-0.33/libm/ceil.c 1970-01-01 00:00:00.000000000 +0000
8845 +++ dietlibc/libm/ceil.c 2015-01-01 12:14:43.498272228 +0000
8847 +/* @(#)s_ceil.c 5.1 93/09/24 */
8849 + * ====================================================
8850 + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
8852 + * Developed at SunPro, a Sun Microsystems, Inc. business.
8853 + * Permission to use, copy, modify, and distribute this
8854 + * software is freely granted, provided that this notice
8856 + * ====================================================
8861 + * Return x rounded toward -inf to integral value
8865 + * Inexact flag raised if x not equal to ceil(x).
8876 +} ieee_double_shape_type;
8878 +/* Get two 32 bit ints from a double. */
8880 +#define EXTRACT_WORDS(ix0,ix1,d) \
8882 + ieee_double_shape_type ew_u; \
8883 + ew_u.value = (d); \
8884 + (ix0) = ew_u.parts.msw; \
8885 + (ix1) = ew_u.parts.lsw; \
8888 +#define INSERT_WORDS(d,ix0,ix1) \
8890 + ieee_double_shape_type iw_u; \
8891 + iw_u.parts.msw = (ix0); \
8892 + iw_u.parts.lsw = (ix1); \
8893 + (d) = iw_u.value; \
8896 +static const double huge = 1.0e300;
8898 +double ceil(double x)
8902 + EXTRACT_WORDS(i0,i1,x);
8903 + j0 = ((i0>>20)&0x7ff)-0x3ff;
8905 + if(j0<0) { /* raise inexact if x != 0 */
8906 + if(huge+x>0.0) {/* return 0*sign(x) if |x|<1 */
8907 + if(i0<0) {i0=0x80000000;i1=0;}
8908 + else if((i0|i1)!=0) { i0=0x3ff00000;i1=0;}
8911 + i = (0x000fffff)>>j0;
8912 + if(((i0&i)|i1)==0) return x; /* x is integral */
8913 + if(huge+x>0.0) { /* raise inexact flag */
8914 + if(i0>0) i0 += (0x00100000)>>j0;
8918 + } else if (j0>51) {
8919 + if(j0==0x400) return x+x; /* inf or NaN */
8920 + else return x; /* x is integral */
8922 + i = ((unsigned int)(0xffffffff))>>(j0-20);
8923 + if((i1&i)==0) return x; /* x is integral */
8924 + if(huge+x>0.0) { /* raise inexact flag */
8928 + j = i1 + (1<<(52-j0));
8929 + if(j<i1) i0+=1; /* got a carry */
8936 + INSERT_WORDS(x,i0,i1);
8939 diff -urN -x .git dietlibc-0.33/libm/gamma.c dietlibc/libm/gamma.c
8940 --- dietlibc-0.33/libm/gamma.c 2005-05-08 15:33:39.000000000 +0000
8941 +++ dietlibc/libm/gamma.c 2015-01-01 12:14:43.498272228 +0000
8946 -#define B0 + 1.0l/ 6/ 1/ 2
8947 -#define B1 - 1.0l/ 30/ 3/ 4
8948 -#define B2 + 1.0l/ 42/ 5/ 6
8949 -#define B3 - 1.0l/ 30/ 7/ 8
8950 -#define B4 + 5.0l/ 66/ 9/10
8951 -#define B5 - 691.0l/2730/11/12
8952 -#define B6 + 7.0l/ 6/13/14
8953 -#define B7 - 3617.0l/ 510/15/16
8954 -#define B8 + 43867.0l/ 798/17/18
8955 -#define B9 - 174611.0l/ 330/19/20
8956 -#define B10 + 854513.0l/ 138/21/22
8957 -#define B11 - 236364091.0l/2730/23/24
8958 -#define B12 + 8553103.0l/ 6/25/26
8959 +#define B0 + 1.0/ 6/ 1/ 2
8960 +#define B1 - 1.0/ 30/ 3/ 4
8961 +#define B2 + 1.0/ 42/ 5/ 6
8962 +#define B3 - 1.0/ 30/ 7/ 8
8963 +#define B4 + 5.0/ 66/ 9/10
8964 +#define B5 - 691.0/2730/11/12
8965 +#define B6 + 7.0/ 6/13/14
8966 +#define B7 - 3617.0/ 510/15/16
8967 +#define B8 + 43867.0/ 798/17/18
8968 +#define B9 - 174611.0/ 330/19/20
8969 +#define B10 + 854513.0/ 138/21/22
8970 +#define B11 - 236364091.0/2730/23/24
8971 +#define B12 + 8553103.0/ 6/25/26
8973 static const double coeff[] = { B0, B1, B2, B3, B4, B5, B6, B7, B8, B9, B10 };
8975 diff -urN -x .git dietlibc-0.33/libpthread/pthread_attr_getscope.c dietlibc/libpthread/pthread_attr_getscope.c
8976 --- dietlibc-0.33/libpthread/pthread_attr_getscope.c 2003-08-18 17:32:52.000000000 +0000
8977 +++ dietlibc/libpthread/pthread_attr_getscope.c 2015-01-01 12:14:43.498272228 +0000
8979 #include "thread_internal.h"
8981 int pthread_attr_getscope(const pthread_attr_t*attr,int*scope) {
8982 - if (0) { attr=0; }
8984 *scope=PTHREAD_SCOPE_SYSTEM;
8987 diff -urN -x .git dietlibc-0.33/libpthread/pthread_attr_setscope.c dietlibc/libpthread/pthread_attr_setscope.c
8988 --- dietlibc-0.33/libpthread/pthread_attr_setscope.c 2003-08-18 17:32:52.000000000 +0000
8989 +++ dietlibc/libpthread/pthread_attr_setscope.c 2015-01-01 12:14:43.498272228 +0000
8991 #include "thread_internal.h"
8993 int pthread_attr_setscope(pthread_attr_t*attr,int scope) {
8994 - if (0) { attr=0; }
8996 if (scope==PTHREAD_SCOPE_SYSTEM) return 0;
8997 if (scope==PTHREAD_SCOPE_PROCESS) return ENOTSUP;
8999 diff -urN -x .git dietlibc-0.33/libpthread/pthread_condattr_getshared.c dietlibc/libpthread/pthread_condattr_getshared.c
9000 --- dietlibc-0.33/libpthread/pthread_condattr_getshared.c 2003-08-18 17:32:53.000000000 +0000
9001 +++ dietlibc/libpthread/pthread_condattr_getshared.c 2015-01-01 12:14:43.498272228 +0000
9003 #include "thread_internal.h"
9005 int pthread_condattr_getpshared(const pthread_condattr_t*attr,int*pshared) {
9006 - if (0) { attr=0; }
9008 *pshared=PTHREAD_PROCESS_PRIVATE;
9011 diff -urN -x .git dietlibc-0.33/libpthread/pthread_condattr_setshared.c dietlibc/libpthread/pthread_condattr_setshared.c
9012 --- dietlibc-0.33/libpthread/pthread_condattr_setshared.c 2003-08-18 17:32:53.000000000 +0000
9013 +++ dietlibc/libpthread/pthread_condattr_setshared.c 2015-01-01 12:14:43.498272228 +0000
9015 #include "thread_internal.h"
9017 int pthread_condattr_setpshared(pthread_condattr_t*attr,int pshared) {
9018 - if (0) { attr=0; }
9020 if ((pshared!=PTHREAD_PROCESS_PRIVATE) && (pshared!=PTHREAD_PROCESS_SHARED))
9022 if (pshared!=PTHREAD_PROCESS_PRIVATE)
9023 diff -urN -x .git dietlibc-0.33/libpthread/pthread_cond_init.c dietlibc/libpthread/pthread_cond_init.c
9024 --- dietlibc-0.33/libpthread/pthread_cond_init.c 2003-08-18 17:32:52.000000000 +0000
9025 +++ dietlibc/libpthread/pthread_cond_init.c 2015-01-01 12:14:43.498272228 +0000
9027 #include "thread_internal.h"
9029 int pthread_cond_init(pthread_cond_t*cond,pthread_condattr_t*cond_attr) {
9030 - if (0) { cond_attr=0; }
9032 memset(cond,0,sizeof(pthread_cond_t));
9033 cond->lock.__spinlock=PTHREAD_SPIN_UNLOCKED;
9035 diff -urN -x .git dietlibc-0.33/libpthread/pthread_errno.c dietlibc/libpthread/pthread_errno.c
9036 --- dietlibc-0.33/libpthread/pthread_errno.c 2001-06-09 17:45:50.000000000 +0000
9037 +++ dietlibc/libpthread/pthread_errno.c 1970-01-01 00:00:00.000000000 +0000
9041 -#include "dietwarning.h"
9043 -link_warning("errno","\e[1;33;41m>>> your multithreaded code uses errno! <<<\e[0m");
9044 diff -urN -x .git dietlibc-0.33/libpthread/pthread_internal.c dietlibc/libpthread/pthread_internal.c
9045 --- dietlibc-0.33/libpthread/pthread_internal.c 2010-09-25 17:03:27.000000000 +0000
9046 +++ dietlibc/libpthread/pthread_internal.c 2015-01-01 12:14:43.498272228 +0000
9049 static void pthread_handle_sigcancel(int sig,siginfo_t*info,void*arg) {
9050 _pthread_descr this=__thread_self();
9051 - if (0) { sig=0; arg=0; }
9052 + (void)sig; (void)arg;
9054 printf("pthread_handle_sigcancel(%d): sigcancel %d\n",sig,this->pid);
9065 diff -urN -x .git dietlibc-0.33/libpthread/pthread_semaphore_misc.c dietlibc/libpthread/pthread_semaphore_misc.c
9066 --- dietlibc-0.33/libpthread/pthread_semaphore_misc.c 2003-09-17 15:06:10.000000000 +0000
9067 +++ dietlibc/libpthread/pthread_semaphore_misc.c 2015-01-01 12:14:43.498272228 +0000
9069 #include "thread_internal.h"
9071 sem_t*sem_open(const char*name,int oflag,...) {
9072 - if (0) { name=0; oflag=0; }
9073 + (void)name; (void)oflag;
9077 int sem_close(sem_t*sem) {
9083 diff -urN -x .git dietlibc-0.33/libpthread/pthread_spinlock.c dietlibc/libpthread/pthread_spinlock.c
9084 --- dietlibc-0.33/libpthread/pthread_spinlock.c 2003-08-18 17:32:53.000000000 +0000
9085 +++ dietlibc/libpthread/pthread_spinlock.c 2015-01-01 12:14:43.498272228 +0000
9093 #include <pthread.h>
9094 #include "thread_internal.h"
9096 +#include <sys/atomic.h>
9097 +#include <sys/futex.h>
9100 +#include <stdlib.h>
9101 +#include <write12.h>
9106 +int __kernel_supports_futex;
9109 void __pthread_lock(struct _pthread_fastlock*lock) {
9113 + if (__kernel_supports_futex==-1) goto old_and_busted;
9114 + /* if we have CAS, use a futex */
9117 + if (__atomic_add(&lock->__spinlock,1)==1)
9118 + /* we now hold the lock, there was no contention */
9120 + __atomic_add(&lock->__spinlock,-1);
9123 + /* slight optimization: if we don't get the lock immediately, busy-loop for a few iterations. */
9125 + for (i=0; i<10; ++i) {
9126 + if (__CAS(&lock->__spinlock,0,1)==0)
9127 + /* we now hold the lock, there was no contention */
9132 + if (__CAS(&lock->__spinlock,1,2)!=1) goto try_again;
9133 + /* if we got here, we did not get the lock. */
9137 + sprintf(buf,"thread %u goes FUTEX_WAIT (lock now %u)\n",gettid(),lock->__spinlock);
9138 + write(1,buf,strlen(buf));
9141 + if (futex(&lock->__spinlock,FUTEX_WAIT,2,NULL,NULL,0)!=0) {
9142 + switch (*__errno_location()) {
9143 + case ENOSYS: /* kernel too old */
9144 + goto old_and_busted;
9145 + case EWOULDBLOCK: /* when futex() looked, the value was no longer -1 */
9146 + case EINTR: /* a signal interrupted us */
9147 + case EDEADLK: /* not in the man page, treat same as EWOULDBLOCK? */
9153 + sprintf(buf,"futex %d",*__errno_location());
9161 + else { /* we waited, the other guy left, we got woken up. */
9163 + sprintf(buf,"thread %u comes out of FUTEX_WAIT (lock now %u)\n",gettid(),lock->__spinlock);
9164 + write(1,buf,strlen(buf));
9170 while (__testandset(&lock->__spinlock)) {
9171 if (cnt<MAX_SPIN_COUNT) {
9176 int __pthread_trylock(struct _pthread_fastlock*lock) {
9178 + if (__kernel_supports_futex==-1) goto old_and_busted;
9179 + /* if we have CAS, use a futex */
9180 + return __CAS(&lock->__spinlock,0,1)!=0;
9183 return __testandset(&lock->__spinlock);
9186 int __pthread_unlock(struct _pthread_fastlock*lock) {
9188 + if (__kernel_supports_futex==-1) goto old_and_busted;
9189 + /* if we have CAS, use a futex */
9190 + if (__CAS(&lock->__spinlock,1,0)!=1) {
9191 + lock->__spinlock=0;
9192 + futex(&lock->__spinlock,FUTEX_WAKE,1,NULL,NULL,0);
9196 + sprintf(buf,"thread %u calls FUTEX_WAKE (lock now %u)\n",gettid(),lock->__spinlock);
9197 + write(1,buf,strlen(buf));
9204 lock->__spinlock=PTHREAD_SPIN_UNLOCKED;
9207 diff -urN -x .git dietlibc-0.33/libpthread/pthread_sys_fcntl.c dietlibc/libpthread/pthread_sys_fcntl.c
9208 --- dietlibc-0.33/libpthread/pthread_sys_fcntl.c 2003-08-18 17:32:53.000000000 +0000
9209 +++ dietlibc/libpthread/pthread_sys_fcntl.c 2015-01-01 12:14:43.498272228 +0000
9211 +#define fcntl lib_fcntl
9214 #include <pthread.h>
9215 #include "thread_internal.h"
9218 int fcntl(int fd, int cmd, void *arg);
9219 int fcntl(int fd, int cmd, void *arg) {
9220 diff -urN -x .git dietlibc-0.33/libregex/rx.c dietlibc/libregex/rx.c
9221 --- dietlibc-0.33/libregex/rx.c 2010-09-25 17:03:27.000000000 +0000
9222 +++ dietlibc/libregex/rx.c 2015-01-01 12:14:43.501605560 +0000
9223 @@ -429,6 +429,12 @@
9226 static int matchempty(void*__restrict__ x,const char*__restrict__ s,int ofs,struct __regex_t*__restrict__ preg,int plus,int eflags) {
9236 @@ -450,10 +456,10 @@
9238 // printf("b->p from %p to ",b->p);
9240 - struct piece* tmp;
9241 - if (!(tmp=realloc(b->p,++b->num*sizeof(p)))) return s;
9242 -// printf("piece realloc: %p -> %p (%d*%d)\n",b->p,tmp,b->num,sizeof(p));
9245 + if (!(t=realloc(b->p,++b->num*sizeof(p)))) return s;
9246 +// printf("piece realloc: %p -> %p (%d*%d)\n",b->p,t,b->num,sizeof(p));
9249 // printf("%p (size %d)\n",b->p,b->num*sizeof(p));
9251 @@ -501,10 +507,10 @@
9252 if (tmp==s && !closebracket(s,p)) return s;
9253 // printf("r->b from %p to ",r->b);
9255 - struct branch* tmp;
9256 - if (!(tmp=realloc(r->b,++r->num*sizeof(b)))) return s;
9257 -// printf("branch realloc: %p -> %p (%d*%d)\n",r->b,tmp,r->num,sizeof(b));
9260 + if (!(t=realloc(r->b,++r->num*sizeof(b)))) return s;
9261 +// printf("branch realloc: %p -> %p (%d*%d)\n",r->b,t,r->num,sizeof(b));
9264 // printf("%p (size %d)\n",r->b,r->num*sizeof(b));
9269 size_t regerror(int errcode, const regex_t*__restrict__ preg, char*__restrict__ errbuf, size_t errbuf_size) {
9272 strncpy(errbuf,"invalid regular expression (sorry)",errbuf_size);
9273 return strlen(errbuf);
9275 diff -urN -x .git dietlibc-0.33/librpc/auth_none.c dietlibc/librpc/auth_none.c
9276 --- dietlibc-0.33/librpc/auth_none.c 2003-08-19 19:34:18.000000000 +0000
9277 +++ dietlibc/librpc/auth_none.c 2015-01-01 12:14:43.504938894 +0000
9280 register struct authnone_private *ap = authnone_private;
9286 return ((*xdrs->x_ops->x_putbytes) (xdrs,
9287 @@ -106,21 +108,24 @@
9289 static void authnone_verf(AUTH *x)
9294 static bool_t authnone_validate(AUTH *x, struct opaque_auth *x1)
9302 static bool_t authnone_refresh(AUTH *x)
9309 static void authnone_destroy(AUTH *x)
9314 diff -urN -x .git dietlibc-0.33/librpc/auth_unix.c dietlibc/librpc/auth_unix.c
9315 --- dietlibc-0.33/librpc/auth_unix.c 2003-08-19 19:34:18.000000000 +0000
9316 +++ dietlibc/librpc/auth_unix.c 2015-01-01 12:14:43.504938894 +0000
9318 static void authunix_nextverf(auth)
9322 /* no action necessary */
9325 diff -urN -x .git dietlibc-0.33/librpc/clnt_perror.c dietlibc/librpc/clnt_perror.c
9326 --- dietlibc-0.33/librpc/clnt_perror.c 2003-08-19 19:34:18.000000000 +0000
9327 +++ dietlibc/librpc/clnt_perror.c 2015-01-01 12:14:43.504938894 +0000
9330 char *clnt_sperror __P ((CLIENT *rpch, const char *s))
9338 char *clnt_sperrno(stat)
9339 enum clnt_stat stat;
9347 char *clnt_spcreateerror __P ((__const char *s))
9351 extern int sys_nerr;
9352 extern char *sys_errlist[];
9353 diff -urN -x .git dietlibc-0.33/librpc/clnt_raw.c dietlibc/librpc/clnt_raw.c
9354 --- dietlibc-0.33/librpc/clnt_raw.c 2003-08-19 19:34:18.000000000 +0000
9355 +++ dietlibc/librpc/clnt_raw.c 2015-01-01 12:14:43.504938894 +0000
9357 CLIENT client_object;
9359 char _raw_buf[UDPMSGSIZE];
9360 - char mashl_callmsg[MCALL_MSG_SIZE];
9362 + struct rpc_msg msg;
9363 + char buf[MCALL_MSG_SIZE];
9369 call_msg.rm_call.cb_rpcvers = RPC_MSG_VERSION;
9370 call_msg.rm_call.cb_prog = prog;
9371 call_msg.rm_call.cb_vers = vers;
9372 - xdrmem_create(xdrs, clp->mashl_callmsg, MCALL_MSG_SIZE, XDR_ENCODE);
9373 + xdrmem_create(xdrs, clp->mashl_call.buf, MCALL_MSG_SIZE, XDR_ENCODE);
9374 if (!xdr_callhdr(xdrs, &call_msg)) {
9375 perror("clnt_raw.c - Fatal header serialization error.");
9378 enum clnt_stat status;
9379 struct rpc_err error;
9384 return (RPC_FAILED);
9388 xdrs->x_op = XDR_ENCODE;
9389 XDR_SETPOS(xdrs, 0);
9390 - ((struct rpc_msg *) clp->mashl_callmsg)->rm_xid++;
9391 - if ((!XDR_PUTBYTES(xdrs, clp->mashl_callmsg, clp->mcnt)) ||
9392 + clp->mashl_call.msg.rm_xid++;
9393 + if ((!XDR_PUTBYTES(xdrs, clp->mashl_call.buf, clp->mcnt)) ||
9394 (!XDR_PUTLONG(xdrs, (long *) &proc)) ||
9395 (!AUTH_MARSHALL(h->cl_auth, xdrs)) || (!(*xargs) (xdrs, argsp))) {
9396 return (RPC_CANTENCODEARGS);
9399 static void clntraw_geterr(CLIENT *x, struct rpc_err *x1)
9407 register XDR *xdrs = &clp->xdr_stream;
9413 rval = (bool_t) RPC_FAILED;
9415 @@ -223,10 +232,14 @@
9417 static bool_t clntraw_control(CLIENT *x, int x1, char *x2)
9425 static void clntraw_destroy(CLIENT *x)
9430 diff -urN -x .git dietlibc-0.33/librpc/clnt_udp.c dietlibc/librpc/clnt_udp.c
9431 --- dietlibc-0.33/librpc/clnt_udp.c 2005-05-08 15:33:39.000000000 +0000
9432 +++ dietlibc/librpc/clnt_udp.c 2015-01-01 12:14:43.504938894 +0000
9436 /* see if reply transaction id matches sent id */
9437 - if (*((uint32_t *) (cu->cu_inbuf)) != *((uint32_t *) (cu->cu_outbuf)))
9438 + if (memcmp(cu->cu_inbuf, cu->cu_outbuf, 4) != 0)
9440 /* we now assume we have the proper reply */
9442 diff -urN -x .git dietlibc-0.33/librpc/pmap_rmt.c dietlibc/librpc/pmap_rmt.c
9443 --- dietlibc-0.33/librpc/pmap_rmt.c 2005-05-08 15:33:39.000000000 +0000
9444 +++ dietlibc/librpc/pmap_rmt.c 2015-01-01 12:14:43.504938894 +0000
9446 int sock; /* any valid socket will do */
9447 char *buf; /* why allocxate more when we can use existing... */
9453 struct sockaddr_in addr;
9455 diff -urN -x .git dietlibc-0.33/librpc/svc_auth_unix.c dietlibc/librpc/svc_auth_unix.c
9456 --- dietlibc-0.33/librpc/svc_auth_unix.c 2007-03-09 13:42:12.000000000 +0000
9457 +++ dietlibc/librpc/svc_auth_unix.c 2015-01-01 12:14:43.504938894 +0000
9459 struct svc_req *rqst;
9460 struct rpc_msg *msg;
9464 return (AUTH_REJECTEDCRED);
9466 diff -urN -x .git dietlibc-0.33/librpc/svc_raw.c dietlibc/librpc/svc_raw.c
9467 --- dietlibc-0.33/librpc/svc_raw.c 2003-08-19 19:34:18.000000000 +0000
9468 +++ dietlibc/librpc/svc_raw.c 2015-01-01 12:14:43.504938894 +0000
9471 static enum xprt_stat svcraw_stat(SVCXPRT *__xprt)
9479 register struct svcraw_private *srp = svcraw_private;
9486 xdrs = &srp->xdr_stream;
9488 register struct svcraw_private *srp = svcraw_private;
9495 xdrs = &srp->xdr_stream;
9498 register struct svcraw_private *srp = svcraw_private;
9504 return ((*xdr_args) (&srp->xdr_stream, args_ptr));
9506 register struct svcraw_private *srp = svcraw_private;
9513 xdrs = &srp->xdr_stream;
9516 static void svcraw_destroy(SVCXPRT *__xprt)
9521 diff -urN -x .git dietlibc-0.33/librpc/svc_tcp.c dietlibc/librpc/svc_tcp.c
9522 --- dietlibc-0.33/librpc/svc_tcp.c 2012-11-02 11:17:28.000000000 +0000
9523 +++ dietlibc/librpc/svc_tcp.c 2015-01-01 12:14:43.504938894 +0000
9525 struct sockaddr_in addr;
9530 r = (struct tcp_rendezvous *) xprt->xp_p1;
9532 len = sizeof(struct sockaddr_in);
9535 static enum xprt_stat rendezvous_stat(SVCXPRT *xprt)
9542 diff -urN -x .git dietlibc-0.33/librpc/svc_udp.c dietlibc/librpc/svc_udp.c
9543 --- dietlibc-0.33/librpc/svc_udp.c 2005-05-08 15:33:39.000000000 +0000
9544 +++ dietlibc/librpc/svc_udp.c 2015-01-01 12:14:43.504938894 +0000
9546 static enum xprt_stat svcudp_stat(xprt)
9554 diff -urN -x .git dietlibc-0.33/librpc/xdr_array.c dietlibc/librpc/xdr_array.c
9555 --- dietlibc-0.33/librpc/xdr_array.c 2002-07-31 21:42:20.000000000 +0000
9556 +++ dietlibc/librpc/xdr_array.c 2015-01-01 12:14:43.504938894 +0000
9559 /* duh, look for integer overflow (fefe) */
9564 - for (i=c; i; --i) {
9565 + for (j=c; j; --j) {
9566 unsigned int tmp=nodesize+elsize;
9567 if (tmp<nodesize) /* overflow */
9569 diff -urN -x .git dietlibc-0.33/librpc/xdr_mem.c dietlibc/librpc/xdr_mem.c
9570 --- dietlibc-0.33/librpc/xdr_mem.c 2012-11-02 11:17:28.000000000 +0000
9571 +++ dietlibc/librpc/xdr_mem.c 2015-01-01 12:14:43.504938894 +0000
9574 xdrmem_destroy (XDR *xdrs)
9580 diff -urN -x .git dietlibc-0.33/librpc/xdr_stdio.c dietlibc/librpc/xdr_stdio.c
9581 --- dietlibc-0.33/librpc/xdr_stdio.c 2003-08-19 19:34:18.000000000 +0000
9582 +++ dietlibc/librpc/xdr_stdio.c 2015-01-01 12:14:43.504938894 +0000
9585 static int32_t *xdrstdio_inline(XDR* xdrs, unsigned int len)
9591 * Must do some work to implement this: must insure
9592 diff -urN -x .git dietlibc-0.33/libstdio/fdglue.c dietlibc/libstdio/fdglue.c
9593 --- dietlibc-0.33/libstdio/fdglue.c 2004-03-02 21:27:19.000000000 +0000
9594 +++ dietlibc/libstdio/fdglue.c 2015-01-01 12:14:43.508272227 +0000
9599 - case 'r': f=O_RDONLY; break;
9600 - case 'w': f=O_WRONLY|O_CREAT|O_TRUNC; break;
9601 - case 'a': f=O_WRONLY|O_CREAT|O_APPEND; break;
9602 + case 'r': f|=O_RDONLY; break;
9603 + case 'w': f|=O_WRONLY|O_CREAT|O_TRUNC; break;
9604 + case 'a': f|=O_WRONLY|O_CREAT|O_APPEND; break;
9605 case '+': f=(f&(~O_WRONLY))|O_RDWR; break;
9608 diff -urN -x .git dietlibc-0.33/libstdio/fflush.c dietlibc/libstdio/fflush.c
9609 --- dietlibc-0.33/libstdio/fflush.c 2012-11-02 11:17:28.000000000 +0000
9610 +++ dietlibc/libstdio/fflush.c 2015-01-01 12:14:43.508272227 +0000
9618 for (res=0, f=__stdio_root; f; f=f->next)
9619 diff -urN -x .git dietlibc-0.33/libstdio/fgets.c dietlibc/libstdio/fgets.c
9620 --- dietlibc-0.33/libstdio/fgets.c 2012-11-02 11:17:28.000000000 +0000
9621 +++ dietlibc/libstdio/fgets.c 2015-01-01 12:14:43.508272227 +0000
9624 char *fgets_unlocked(char *s, int size, FILE *stream) {
9626 - for (l=0; l<size; ) {
9627 + if (size<=0) return 0;
9628 + for (l=0; l+1<size; ) {
9630 if (l && __likely(stream->bm<stream->bs)) {
9631 /* try common case first */
9633 c=fgetc_unlocked(stream);
9634 if (__unlikely(c==EOF)) {
9647 + if (c=='\n') break;
9653 diff -urN -x .git dietlibc-0.33/libstdio/fread.c dietlibc/libstdio/fread.c
9654 --- dietlibc-0.33/libstdio/fread.c 2005-09-28 06:18:44.000000000 +0000
9655 +++ dietlibc/libstdio/fread.c 2015-01-01 12:14:43.508272227 +0000
9659 size_t fread_unlocked(void *ptr, size_t size, size_t nmemb, FILE *stream) {
9669 res=fgetc_unlocked(stream);
9672 diff -urN -x .git dietlibc-0.33/libugly/asctime.c dietlibc/libugly/asctime.c
9673 --- dietlibc-0.33/libugly/asctime.c 2001-02-01 22:14:06.000000000 +0000
9674 +++ dietlibc/libugly/asctime.c 2015-01-01 12:14:43.508272227 +0000
9678 -static char buf[25];
9679 +static char buf[26];
9681 char *asctime(const struct tm *timeptr) {
9682 return asctime_r(timeptr,buf);
9683 diff -urN -x .git dietlibc-0.33/libugly/asctime_r.c dietlibc/libugly/asctime_r.c
9684 --- dietlibc-0.33/libugly/asctime_r.c 2001-07-20 13:10:07.000000000 +0000
9685 +++ dietlibc/libugly/asctime_r.c 2015-01-01 12:14:43.508272227 +0000
9689 char *asctime_r(const struct tm *t, char *buf) {
9690 - /* "Wed Jun 30 21:49:08 1993\n" */
9691 + /* "Wed Jun 30 21:49:08 1993\n\0" */
9692 *(int*)buf=*(int*)(days+(t->tm_wday<<2));
9693 *(int*)(buf+4)=*(int*)(months+(t->tm_mon<<2));
9694 num2str(buf+8,t->tm_mday);
9696 num2str(buf+20,(t->tm_year+1900)/100);
9697 num2str(buf+22,(t->tm_year+1900)%100);
9702 diff -urN -x .git dietlibc-0.33/libugly/gethostent.c dietlibc/libugly/gethostent.c
9703 --- dietlibc-0.33/libugly/gethostent.c 2003-06-23 10:48:13.000000000 +0000
9704 +++ dietlibc/libugly/gethostent.c 2015-01-01 12:14:43.511605561 +0000
9706 while (cur<last && !isspace(*cur)) ++cur;
9708 char *from=pe->h_aliases[aliasidx];
9710 - if (max-dest<len+2) goto nospace;
9712 + if (max-dest<l+2) goto nospace;
9713 pe->h_aliases[aliasidx]=dest;
9714 memmove(dest,from,(size_t)(cur-from));
9719 if (*cur=='\n') { ++cur; ++aliasidx; break; }
9720 diff -urN -x .git dietlibc-0.33/libugly/strftime.c dietlibc/libugly/strftime.c
9721 --- dietlibc-0.33/libugly/strftime.c 2012-04-19 16:50:23.000000000 +0000
9722 +++ dietlibc/libugly/strftime.c 2015-01-01 12:14:43.514938893 +0000
9727 -// case '%': *p++ = '%'; break; // reduce size of jump table
9728 - case 'n': *p++ = '\n'; break;
9729 - case 't': *p++ = '\t'; break;
9730 +// case '%': *p++ = '%'; break; // reduce size of jump table
9731 + case 'n': *p++ = '\n'; break;
9732 + case 't': *p++ = '\t'; break;
9733 case 'O': case 'E': ++format; goto again;
9734 - case 'c': src = "%b %a %d %k:%M:%S %Z %Y"; goto _strf;
9735 - case 'r': src = "%I:%M:%S %p"; goto _strf;
9736 - case 'R': src = "%H:%M"; goto _strf;
9737 - case 'x': src = "%b %a %d"; goto _strf;
9738 - case 'X': src = "%k:%M:%S"; goto _strf;
9739 - case 'D': src = "%m/%d/%y"; goto _strf;
9740 + case 'c': src = "%b %a %d %k:%M:%S %Z %Y"; goto _strf;
9741 + case 'r': src = "%I:%M:%S %p"; goto _strf;
9742 + case 'R': src = "%H:%M"; goto _strf;
9743 + case 'x': src = "%b %a %d"; goto _strf;
9744 + case 'X': src = "%k:%M:%S"; goto _strf;
9745 + case 'D': src = "%m/%d/%y"; goto _strf;
9746 + case 'F': src = "%Y-%m-%d"; goto _strf;
9747 case 'T': src = "%H:%M:%S";
9748 _strf: p += strftime (p, (size_t)(dst+max-p), src, tm); break;
9749 - case 'a': src = sweekdays [tm->tm_wday]; goto _str;
9750 - case 'A': src = weekdays [tm->tm_wday]; goto _str;
9751 + case 'a': src = sweekdays [tm->tm_wday]; goto _str;
9752 + case 'A': src = weekdays [tm->tm_wday]; goto _str;
9754 - case 'b': src = smonths [tm->tm_mon]; goto _str;
9755 - case 'B': src = months [tm->tm_mon]; goto _str;
9756 + case 'b': src = smonths [tm->tm_mon]; goto _str;
9757 + case 'B': src = months [tm->tm_mon]; goto _str;
9758 case 'p': src = ampm [tm->tm_hour > 12 ? 3 : 2]; goto _str;
9759 case 'P': src = ampm [tm->tm_hour > 12 ? 1 : 0]; goto _str;
9760 - case 'C': no = tm->tm_year/100 + 19; goto _no;
9761 - case 'd': no = tm->tm_mday; goto _no;
9762 - case 'e': no = tm->tm_mday; goto _nos;
9763 - case 'H': no = tm->tm_hour; goto _no;
9764 - case 'I': no = tm->tm_hour % 12; goto _no;
9765 - case 'j': no = tm->tm_yday; goto _no;
9766 - case 'k': no = tm->tm_hour; goto _nos;
9767 - case 'l': no = tm->tm_hour % 12; goto _nos;
9768 - case 'm': no = tm->tm_mon + 1; goto _no;
9769 - case 'M': no = tm->tm_min; goto _no;
9770 - case 'S': no = tm->tm_sec; goto _no;
9771 - case 'u': no = tm->tm_wday ? tm->tm_wday : 7; goto _no;
9772 - case 'w': no = tm->tm_wday; goto _no;
9773 + case 'C': no = tm->tm_year/100 + 19; goto _no;
9774 + case 'd': no = tm->tm_mday; goto _no;
9775 + case 'e': no = tm->tm_mday; goto _nos;
9776 + case 'H': no = tm->tm_hour; goto _no;
9777 + case 'I': no = tm->tm_hour % 12; goto _no;
9778 + case 'j': no = tm->tm_yday; goto _no;
9779 + case 'k': no = tm->tm_hour; goto _nos;
9780 + case 'l': no = tm->tm_hour % 12; goto _nos;
9781 + case 'm': no = tm->tm_mon + 1; goto _no;
9782 + case 'M': no = tm->tm_min; goto _no;
9783 + case 'S': no = tm->tm_sec; goto _no;
9784 + case 'u': no = tm->tm_wday ? tm->tm_wday : 7; goto _no;
9785 + case 'w': no = tm->tm_wday; goto _no;
9786 case 'U': no = (tm->tm_yday - tm->tm_wday + 7) / 7; goto _no;
9787 case 'W': no = (tm->tm_yday - (tm->tm_wday - 1 + 7) % 7 + 7) / 7; goto _no;
9789 time_t t = mktime((struct tm*)tm);
9794 - for (c=buf+99; c>buf; --c) {
9796 + for (c=sbuf+99; c>sbuf; --c) {
9800 diff -urN -x .git dietlibc-0.33/libugly/strptime.c dietlibc/libugly/strptime.c
9801 --- dietlibc-0.33/libugly/strptime.c 2008-12-10 20:00:59.000000000 +0000
9802 +++ dietlibc/libugly/strptime.c 2015-01-01 12:14:43.514938893 +0000
9803 @@ -119,10 +119,10 @@
9807 - s=strptime(s,"%b %a %d",tm);
9808 + s=strptime(s,"%m/%d/%y",tm);
9811 - s=strptime(s,"%k:%M:%S",tm);
9812 + s=strptime(s,"%H:%M:%S",tm);
9816 diff -urN -x .git dietlibc-0.33/libugly/timegm.c dietlibc/libugly/timegm.c
9817 --- dietlibc-0.33/libugly/timegm.c 2005-01-31 12:53:34.000000000 +0000
9818 +++ dietlibc/libugly/timegm.c 2015-01-01 12:14:43.514938893 +0000
9820 if (t->tm_min>60) { t->tm_hour += t->tm_min/60; t->tm_min%=60; }
9821 if (t->tm_hour>60) { t->tm_mday += t->tm_hour/60; t->tm_hour%=60; }
9822 if (t->tm_mon>12) { t->tm_year += t->tm_mon/12; t->tm_mon%=12; }
9823 + if (t->tm_mon<0) t->tm_mon=0;
9824 while (t->tm_mday>__spm[1+t->tm_mon]) {
9825 if (t->tm_mon==1 && __isleap(t->tm_year+1900)) {
9826 if (t->tm_mon==31+29) break;
9827 diff -urN -x .git dietlibc-0.33/linuxnet.h dietlibc/linuxnet.h
9828 --- dietlibc-0.33/linuxnet.h 2001-06-16 17:49:29.000000000 +0000
9829 +++ dietlibc/linuxnet.h 2015-01-01 12:14:43.514938893 +0000
9831 #define SYS_GETSOCKOPT 15 /* sys_getsockopt(2) */
9832 #define SYS_SENDMSG 16 /* sys_sendmsg(2) */
9833 #define SYS_RECVMSG 17 /* sys_recvmsg(2) */
9834 +#define SYS_ACCEPT4 18 /* sys_accept4(2) */
9835 +#define SYS_RECVMMSG 19 /* sys_recvmmsg(2) */
9836 +#define SYS_SENDMMSG 20 /* sys_sendmmsg(2) */
9838 diff -urN -x .git dietlibc-0.33/Makefile dietlibc/Makefile
9839 --- dietlibc-0.33/Makefile 2012-11-02 11:17:28.000000000 +0000
9840 +++ dietlibc/Makefile 2015-01-01 12:14:43.451605563 +0000
9842 BINDIR=${prefix}/bin
9843 MAN1DIR=${prefix}/man/man1
9845 -MYARCH:=$(shell uname -m | sed -e 's/i[4-9]86/i386/' -e 's/armv[3-6]t\?e\?[lb]/arm/')
9848 +MYARCH:=$(shell uname -m | sed -e 's/i[4-9]86/i386/' -e 's/armv[3-7]t\?[eh]\?j\?[lb]/arm/')
9850 # This extra-ugly cruft is here so make will not run uname and sed each
9851 # time it looks at $(OBJDIR). This alone sped up running make when
9852 @@ -100,10 +102,13 @@
9854 profiling: $(OBJDIR)/libgmon.a $(OBJDIR)/pstart.o
9856 -CFLAGS=-pipe -nostdinc
9857 +DEFAULTCFLAGS=-pipe -nostdinc -D_REENTRANT $(EXTRACFLAGS)
9858 +CFLAGS=$(DEFAULTCFLAGS)
9863 +STRIP=$(COMMENT) $(CROSS)strip
9864 INC=-I. -isystem include
9866 VPATH=lib:libstdio:libugly:libcruft:libcrypt:libshell:liblatin1:libcompat:libdl:librpc:libregex:libm:profiling
9867 @@ -128,19 +133,26 @@
9869 LIBGMON_OBJS=$(OBJDIR)/__mcount.o $(OBJDIR)/monitor.o $(OBJDIR)/profil.o
9871 +NO_STACK_PROTECTOR=stackgap.o __get_elf_aux_value.o
9873 include $(ARCH)/Makefile.add
9875 LIBMATHOBJ=$(patsubst %,$(OBJDIR)/%,$(LIBMATH))
9877 -ifeq ($(CFLAGS),-pipe -nostdinc)
9878 +ifeq ($(CFLAGS),$(DEFAULTCFLAGS))
9879 CFLAGS+=-O -fomit-frame-pointer
9887 +CFLAGS += -W -Wall -Wextra -Wchar-subscripts -Wmissing-prototypes -Wmissing-declarations -Wno-switch -Wno-unused -Wredundant-decls -Wshadow
9889 +ASM_CFLAGS = -Wa,--noexecstack
9890 +ifneq ($(subst clang,fnord,$(CC)),$(CC))
9891 +ASM_CFLAGS += -fno-integrated-as
9893 -CFLAGS += -W -Wall -Wextra -Wchar-subscripts -Wmissing-prototypes -Wmissing-declarations -Wno-switch -Wno-unused -Wredundant-decls
9897 @@ -155,31 +167,35 @@
9901 -$(OBJDIR)/%: $(OBJDIR)
9904 -$(OBJDIR)/%.o: %.S $(ARCH)/syscalls.h
9905 - $(CROSS)cpp $(INC) $< | $(CROSS)as -o $@
9906 +$(OBJDIR)/%.o: %.S $(ARCH)/syscalls.h | $(OBJDIR)
9907 + $(CROSS)cpp $(INC) $< | $(CROSS)as --noexecstack -o $@
9910 +$(OBJDIR)/%.o: %.c | $(OBJDIR)
9911 tcc -I. -Iinclude -c $< -o $@
9912 - $(COMMENT) -$(CROSS)strip -x -R .comment -R .note $@
9913 + -$(STRIP) -x -R .comment -R .note $@
9915 -$(OBJDIR)/pstart.o: start.S
9916 - $(CROSS)$(CC) $(INC) $(CFLAGS) -DPROFILING -c $< -o $@
9917 +$(OBJDIR)/pstart.o: start.S | $(OBJDIR)
9918 + $(CCC) $(INC) $(CFLAGS) $(EXTRACFLAGS) -DPROFILING -c $< $(ASM_CFLAGS) -o $@
9920 +$(OBJDIR)/%.o: %.S $(ARCH)/syscalls.h | $(OBJDIR)
9921 + $(CCC) $(INC) $(CFLAGS) $(EXTRACFLAGS) -c $< $(ASM_CFLAGS) -o $@
9923 -$(OBJDIR)/%.o: %.S $(ARCH)/syscalls.h
9924 - $(CROSS)$(CC) $(INC) $(CFLAGS) -c $< -o $@
9925 +$(OBJDIR)/pthread_%.o: libpthread/pthread_%.c | $(OBJDIR)
9926 + $(CCC) $(INC) $(CFLAGS) $(EXTRACFLAGS) -c $< -o $@
9927 + -$(STRIP) -x -R .comment -R .note $@
9928 +$(OBJDIR)/stack_smash_handler2.o: EXTRACFLAGS:=-fno-omit-frame-pointer
9930 -$(OBJDIR)/pthread_%.o: libpthread/pthread_%.c
9931 - $(CROSS)$(CC) $(INC) $(CFLAGS) -c $< -o $@
9932 - $(COMMENT) -$(CROSS)strip -x -R .comment -R .note $@
9933 +$(OBJDIR)/%.o: %.c | $(OBJDIR)
9934 + $(CCC) $(INC) $(CFLAGS) $(EXTRACFLAGS) -c $< -o $@ -D__dietlibc__
9935 + -$(STRIP) -x -R .comment -R .note $@
9938 - $(CROSS)$(CC) $(INC) $(CFLAGS) -c $< -o $@ -D__dietlibc__
9939 - $(COMMENT) -$(CROSS)strip -x -R .comment -R .note $@
9940 +$(addprefix $(OBJDIR)/,$(NO_STACK_PROTECTOR)) \
9941 +$(addprefix $(PICODIR)/,$(NO_STACKPROTECTOR)): EXTRACFLAGS+=-fno-stack-protector
9946 ifeq ($(shell $(CC) -v 2>&1 | grep "gcc version"),gcc version 4.0.0)
9947 SAFE_CFLAGS=$(shell echo $(CFLAGS)|sed 's/-Os/-O2/')
9948 SAFER_CFLAGS=$(shell echo $(CFLAGS)|sed 's/-Os/-O/')
9953 -$(OBJDIR)/crypt.o: libcrypt/crypt.c
9954 - $(CROSS)$(CC) $(INC) $(SAFER_CFLAGS) -c $< -o $@
9955 +$(OBJDIR)/crypt.o: libcrypt/crypt.c | $(OBJDIR)
9956 + $(CCC) $(INC) $(SAFER_CFLAGS) $(EXTRACFLAGS) -c $< -o $@
9958 DIETLIBC_OBJ = $(OBJDIR)/unified.o \
9959 $(SYSCALLOBJ) $(LIBOBJ) $(LIBSTDIOOBJ) $(LIBUGLYOBJ) \
9961 $(OBJDIR)/librpc.a: $(LIBRPCOBJ)
9962 $(CROSS)ar cru $@ $(LIBRPCOBJ)
9964 -$(OBJDIR)/libcrypt.a:
9965 +$(OBJDIR)/libcrypt.a: | $(OBJDIR)
9967 - $(CROSS)$(CC) -c dummy.c
9969 $(CROSS)ar cru $@ dummy.o
9970 rm -f dummy.c dummy.o
9972 @@ -242,23 +258,23 @@
9973 $(PICODIR)/libpthread.so $(PICODIR)/libdl.so $(PICODIR)/libcompat.so \
9974 $(PICODIR)/libm.so $(PICODIR)/diet-dyn $(PICODIR)/diet-dyn-i
9976 -$(PICODIR)/%.o: %.S $(ARCH)/syscalls.h
9977 - $(CROSS)$(CC) $(INC) $(CFLAGS) -fPIC -D__DYN_LIB -c $< -o $@
9978 +$(PICODIR)/%.o: %.S $(ARCH)/syscalls.h | $(PICODIR)
9979 + $(CCC) $(INC) $(CFLAGS) $(EXTRACFLAGS) -fPIC -D__DYN_LIB $(ASM_CFLAGS) -c $< -o $@
9981 -$(PICODIR)/pthread_%.o: libpthread/pthread_%.c
9982 - $(CROSS)$(CC) $(INC) $(CFLAGS) -fPIC -D__DYN_LIB -c $< -o $@
9983 - $(COMMENT) $(CROSS)strip -x -R .comment -R .note $@
9985 -$(PICODIR)/%.o: %.c
9986 - $(CROSS)$(CC) $(INC) $(CFLAGS) -fPIC -D__DYN_LIB -c $< -o $@
9987 - $(COMMENT) $(CROSS)strip -x -R .comment -R .note $@
9989 -$(PICODIR)/dstart.o: start.S
9990 - $(CROSS)$(CC) $(INC) $(CFLAGS) -fPIC -D__DYN_LIB -c $< -o $@
9992 -$(PICODIR)/dyn_so_start.o: dyn_start.c
9993 - $(CROSS)$(CC) $(INC) $(CFLAGS) -fPIC -D__DYN_LIB -D__DYN_LIB_SHARED -c $< -o $@
9994 - $(COMMENT) $(CROSS)strip -x -R .comment -R .note $@
9995 +$(PICODIR)/pthread_%.o: libpthread/pthread_%.c | $(PICODIR)
9996 + $(CCC) $(INC) $(CFLAGS) $(EXTRACFLAGS) -fPIC -D__DYN_LIB -c $< -o $@
9997 + $(STRIP) -x -R .comment -R .note $@
9999 +$(PICODIR)/%.o: %.c | $(PICODIR)
10000 + $(CCC) $(INC) $(CFLAGS) $(EXTRACFLAGS) -fPIC -D__DYN_LIB -c $< -o $@
10001 + $(STRIP) -x -R .comment -R .note $@
10003 +$(PICODIR)/dstart.o: start.S | $(PICODIR)
10004 + $(CCC) $(INC) $(CFLAGS) $(EXTRACFLAGS) -fPIC -D__DYN_LIB $(ASM_CFLAGS) -c $< -o $@
10006 +$(PICODIR)/dyn_so_start.o: dyn_start.c | $(PICODIR)
10007 + $(CCC) $(INC) $(CFLAGS) $(EXTRACFLAGS) -fPIC -D__DYN_LIB -D__DYN_LIB_SHARED -c $< -o $@
10008 + $(STRIP) -x -R .comment -R .note $@
10010 DYN_LIBC_PIC = $(LIBOBJ) $(LIBSTDIOOBJ) $(LIBUGLYOBJ) \
10011 $(LIBCRUFTOBJ) $(LIBCRYPTOBJ) $(LIBSHELLOBJ) $(LIBREGEXOBJ)
10012 @@ -274,55 +290,55 @@
10014 DYN_LIBMATH_OBJS = $(patsubst $(OBJDIR)/%.o,$(PICODIR)/%.o,$(LIBMATHOBJ))
10016 -$(PICODIR)/libc.so: $(PICODIR) $(DYN_LIBC_OBJ)
10017 - $(LD_UNSET) $(CROSS)$(CC) -nostdlib -shared -o $@ $(CFLAGS) -fPIC $(DYN_LIBC_OBJ) -lgcc -Wl,-soname=libc.so
10018 +$(PICODIR)/libc.so: $(DYN_LIBC_OBJ)
10019 + $(LD_UNSET) $(CCC) -nostdlib -shared -o $@ $(CFLAGS) -fPIC $(DYN_LIBC_OBJ) -lgcc -Wl,-soname=libc.so
10021 -$(PICODIR)/libpthread.so: $(DYN_PTHREAD_OBJS) dietfeatures.h
10022 - $(LD_UNSET) $(CROSS)$(CC) -nostdlib -shared -o $@ $(CFLAGS) -fPIC $(DYN_PTHREAD_OBJS) -L$(PICODIR) -lc -Wl,-soname=libpthread.so
10023 +$(PICODIR)/libpthread.so: $(DYN_PTHREAD_OBJS) dietfeatures.h $(PICODIR)/libc.so
10024 + $(LD_UNSET) $(CCC) -nostdlib -shared -o $@ $(CFLAGS) -fPIC $(DYN_PTHREAD_OBJS) -L$(PICODIR) -lc -Wl,-soname=libpthread.so
10026 -$(PICODIR)/libdl.so: libdl/_dl_main.c dietfeatures.h
10027 - $(LD_UNSET) $(CROSS)$(CC) -D__OD_CLEAN_ROOM -DNODIETREF -fPIC -nostdlib -shared -Bsymbolic -Wl,-Bsymbolic \
10028 +$(PICODIR)/libdl.so: libdl/_dl_main.c dietfeatures.h $(PICODIR)/libc.so
10029 + $(LD_UNSET) $(CCC) -D__OD_CLEAN_ROOM -DNODIETREF -fPIC -nostdlib -shared -Bsymbolic -Wl,-Bsymbolic \
10030 -o $@ $(SAFE_CFLAGS) $(INC) libdl/_dl_main.c -Wl,-soname=libdl.so
10032 $(OBJDIR)/pthread_create.o $(PICODIR)/pthread_create.o: dietfeatures.h
10033 $(OBJDIR)/pthread_internal.o $(PICODIR)/pthread_internal.o: dietfeatures.h
10035 #$(PICODIR)/libdl.so: $(DYN_LIBDL_OBJS) dietfeatures.h
10036 -# $(CROSS)$(CC) -nostdlib -shared -o $@ $(CFLAGS) -fPIC $(DYN_LIBDL_OBJS) -L$(PICODIR) -ldietc -Wl,-soname=libdl.so
10037 +# $(CCC) -nostdlib -shared -o $@ $(CFLAGS) -fPIC $(DYN_LIBDL_OBJS) -L$(PICODIR) -ldietc -Wl,-soname=libdl.so
10039 -$(PICODIR)/libcompat.so: $(DYN_LIBCOMPAT_OBJS) dietfeatures.h
10040 - $(LD_UNSET) $(CROSS)$(CC) -nostdlib -shared -o $@ $(CFLAGS) -fPIC $(DYN_LIBCOMPAT_OBJS) -L$(PICODIR) -lc -Wl,-soname=libcompat.so
10041 +$(PICODIR)/libcompat.so: $(DYN_LIBCOMPAT_OBJS) dietfeatures.h $(PICODIR)/libc.so
10042 + $(LD_UNSET) $(CCC) -nostdlib -shared -o $@ $(CFLAGS) -fPIC $(DYN_LIBCOMPAT_OBJS) -L$(PICODIR) -lc -Wl,-soname=libcompat.so
10044 -$(PICODIR)/libm.so: $(DYN_LIBMATH_OBJS) dietfeatures.h
10045 - $(LD_UNSET) $(CROSS)$(CC) -nostdlib -shared -o $@ $(CFLAGS) -fPIC $(DYN_LIBMATH_OBJS) -L$(PICODIR) -lc -Wl,-soname=libm.so
10046 +$(PICODIR)/libm.so: $(DYN_LIBMATH_OBJS) dietfeatures.h $(PICODIR)/libc.so
10047 + $(LD_UNSET) $(CCC) -nostdlib -shared -o $@ $(CFLAGS) -fPIC $(DYN_LIBMATH_OBJS) -L$(PICODIR) -lc -Wl,-soname=libm.so
10050 $(SYSCALLOBJ): syscalls.h
10052 $(OBJDIR)/elftrunc: $(OBJDIR)/diet contrib/elftrunc.c
10053 - bin-$(MYARCH)/diet $(CROSS)$(CC) $(CFLAGS) -o $@ contrib/elftrunc.c
10054 + bin-$(MYARCH)/diet $(CCC) $(CFLAGS) -o $@ contrib/elftrunc.c
10056 $(OBJDIR)/dnsd: $(OBJDIR)/diet contrib/dnsd.c
10057 - bin-$(MYARCH)/diet $(CROSS)$(CC) $(CFLAGS) -o $@ contrib/dnsd.c
10058 + bin-$(MYARCH)/diet $(CCC) $(CFLAGS) -o $@ contrib/dnsd.c
10060 VERSION=dietlibc-$(shell head -n 1 CHANGES|sed 's/://')
10061 CURNAME=$(notdir $(shell pwd))
10063 $(OBJDIR)/diet: $(OBJDIR)/start.o $(OBJDIR)/dyn_start.o diet.c $(OBJDIR)/dietlibc.a $(OBJDIR)/dyn_stop.o
10064 - $(CROSS)$(CC) -isystem include $(CFLAGS) -nostdlib -o $@ $^ -DDIETHOME=\"$(HOME)\" -DVERSION=\"$(VERSION)\" -lgcc
10065 - $(CROSS)strip -R .comment -R .note $@
10066 + $(CCC) -isystem include $(CFLAGS) -nostdlib -o $@ $^ -DDIETHOME=\"$(HOME)\" -DVERSION=\"$(VERSION)\" -lgcc
10067 + $(STRIP) -R .comment -R .note $@
10069 $(OBJDIR)/diet-i: $(OBJDIR)/start.o $(OBJDIR)/dyn_start.o diet.c $(OBJDIR)/dietlibc.a $(OBJDIR)/dyn_stop.o
10070 - $(CROSS)$(CC) -isystem include $(CFLAGS) -nostdlib -o $@ $^ -DDIETHOME=\"$(prefix)\" -DVERSION=\"$(VERSION)\" -DINSTALLVERSION -lgcc
10071 - $(CROSS)strip -R .comment -R .note $@
10072 + $(CCC) -isystem include $(CFLAGS) -nostdlib -o $@ $^ -DDIETHOME=\"$(prefix)\" -DVERSION=\"$(VERSION)\" -DINSTALLVERSION -lgcc
10073 + $(STRIP) -R .comment -R .note $@
10075 $(PICODIR)/diet-dyn: $(PICODIR)/start.o $(PICODIR)/dyn_start.o diet.c
10076 - $(LD_UNSET) $(CROSS)$(CC) -isystem include $(CFLAGS) -fPIC -nostdlib -o $@ $^ -DDIETHOME=\"$(HOME)\" -D__DYN_LIB -DVERSION=\"$(VERSION)\" -L$(PICODIR) -lc -lgcc $(PICODIR)/dyn_stop.o -Wl,-dynamic-linker=$(HOME)/$(PICODIR)/libdl.so
10077 - $(CROSS)strip -R .command -R .note $@
10078 + $(LD_UNSET) $(CCC) -isystem include $(CFLAGS) -fPIC -nostdlib -o $@ $^ -DDIETHOME=\"$(HOME)\" -D__DYN_LIB -DVERSION=\"$(VERSION)\" -L$(PICODIR) -lc -lgcc $(PICODIR)/dyn_stop.o -Wl,-dynamic-linker=$(HOME)/$(PICODIR)/libdl.so
10079 + $(STRIP) -R .command -R .note $@
10081 $(PICODIR)/diet-dyn-i: $(PICODIR)/start.o $(PICODIR)/dyn_start.o diet.c
10082 - $(LD_UNSET) $(CROSS)$(CC) -isystem include $(CFLAGS) -fPIC -nostdlib -o $@ $^ -DDIETHOME=\"$(prefix)\" -D__DYN_LIB -DVERSION=\"$(VERSION)\" -L$(PICODIR) -lc -lgcc $(PICODIR)/dyn_stop.o -Wl,-dynamic-linker=$(ILIBDIR)/libdl.so -DINSTALLVERSION
10083 - $(CROSS)strip -R .command -R .note $@
10084 + $(LD_UNSET) $(CCC) -isystem include $(CFLAGS) -fPIC -nostdlib -o $@ $^ -DDIETHOME=\"$(prefix)\" -D__DYN_LIB -DVERSION=\"$(VERSION)\" -L$(PICODIR) -lc -lgcc $(PICODIR)/dyn_stop.o -Wl,-dynamic-linker=$(ILIBDIR)/libdl.so -DINSTALLVERSION
10085 + $(STRIP) -R .command -R .note $@
10087 $(OBJDIR)/djb: $(OBJDIR)/compile $(OBJDIR)/load
10089 @@ -335,7 +351,7 @@
10093 - rm -f *.o *.a t t1 compile load elftrunc exports mapfile libdietc.so
10094 + rm -f *.o *.a t t1 compile load elftrunc exports mapfile libdietc.so include/errno_definition.h
10096 $(MAKE) -C examples clean
10097 $(MAKE) -C dynlinker clean
10098 @@ -352,14 +368,14 @@
10102 - $(CROSS)$(CC) -g $(CFLAGS) -fno-builtin -nostdlib -isystem include -o t t.c $(OBJDIR)/start.o $(OBJDIR)/dyn_start.o $(OBJDIR)/dietlibc.a -lgcc $(OBJDIR)/dyn_stop.o -Wl,-Map,mapfile
10103 + $(CCC) -g $(CFLAGS) -fno-builtin -nostdlib -isystem include -o t t.c $(OBJDIR)/start.o $(OBJDIR)/dyn_start.o $(OBJDIR)/dietlibc.a -lgcc $(OBJDIR)/dyn_stop.o -Wl,-Map,mapfile
10106 - $(CROSS)$(CC) -g -o t1 t.c
10107 + $(CCC) -g -o t1 t.c
10109 install-bin: $(OBJDIR)/start.o $(OBJDIR)/dietlibc.a $(OBJDIR)/librpc.a $(OBJDIR)/liblatin1.a $(OBJDIR)/libcompat.a $(OBJDIR)/elftrunc $(OBJDIR)/diet-i
10110 $(INSTALL) -d $(DESTDIR)$(ILIBDIR) $(DESTDIR)$(MAN1DIR) $(DESTDIR)$(BINDIR)
10111 - $(INSTALL) $(OBJDIR)/start.o $(DESTDIR)$(ILIBDIR)/start.o
10112 + $(INSTALL) -m 644 $(OBJDIR)/start.o $(OBJDIR)/dyn_start.o $(OBJDIR)/dyn_stop.o $(DESTDIR)$(ILIBDIR)/
10113 $(INSTALL) -m 644 $(OBJDIR)/libm.a $(OBJDIR)/libpthread.a $(OBJDIR)/librpc.a \
10114 $(OBJDIR)/liblatin1.a $(OBJDIR)/libcompat.a $(OBJDIR)/libcrypt.a $(DESTDIR)$(ILIBDIR)
10115 $(INSTALL) -m 644 $(OBJDIR)/dietlibc.a $(DESTDIR)$(ILIBDIR)/libc.a
10116 @@ -371,7 +387,7 @@
10117 $(INSTALL) -m 644 diet.1 $(DESTDIR)$(MAN1DIR)/diet.1
10120 - -$(INSTALL) $(OBJDIR)/pstart.o $(OBJDIR)/libgmon.a $(OBJDIR)/dyn_start.o $(OBJDIR)/dyn_stop.o $(DESTDIR)$(ILIBDIR)
10121 + -$(INSTALL) $(OBJDIR)/pstart.o $(OBJDIR)/libgmon.a $(DESTDIR)$(ILIBDIR)
10124 -$(INSTALL) $(PICODIR)/libc.so $(DESTDIR)$(ILIBDIR)/libc.so
10125 @@ -445,6 +461,10 @@
10127 $(MAKE) $(subst $(ARCH),,$(CROSS_ARCH))
10129 +# DOES NOT WORK YET
10131 + ARCH=mips64 CROSS=mips64-linux- CC="gcc -mabi=64"
10134 # these depend on dietfeatures.h for large file backward compatibility
10135 $(OBJDIR)/__fstat64.o $(OBJDIR)/__lstat64.o $(OBJDIR)/__stat64.o $(OBJDIR)/lseek64.o $(OBJDIR)/readdir64.o $(OBJDIR)/stat64.o $(OBJDIR)/lstat64.o $(OBJDIR)/fstat64.o $(OBJDIR)/truncate64.o $(OBJDIR)/__truncate64.o $(OBJDIR)/ftruncate64.o $(OBJDIR)/__ftruncate64.o $(OBJDIR)/sendfile64.o $(OBJDIR)/__sendfile64.o $(PICODIR)/dyn_syscalls.o $(PICODIR)/__truncate64.o $(PICODIR)/__ftruncate64.o $(PICODIR)/__stat64.o $(PICODIR)/__lstat64.o $(PICODIR)/__fstat64.o $(OBJDIR)/__sendfile64.o $(OBJDIR)/fstatfs64.o $(OBJDIR)/statfs64.o: dietfeatures.h
10136 @@ -519,6 +539,10 @@
10137 # these depend on dietfeatures.h for WANT_INET_ADDR_DNS
10138 $(OBJDIR)/gethostbyname_r.o: dietfeatures.h
10140 +# these depend on dietfeatures.h for WANT_VALGRIND_SUPPORT
10141 +bin-x86_64/strlen.o bin-x86_64/memchr.o bin-x86_64/gettimeofday.o: dietfeatures.h
10142 +bin-x32/strlen.o bin-x32/memchr.o bin-x32/gettimeofday.o: dietfeatures.h
10144 # WANT_PLUGPLAY_DNS
10145 $(OBJDIR)/getaddrinfo.o: dietfeatures.h
10147 @@ -531,11 +555,84 @@
10148 # WANT_LARGEFILE_BACKCOMPAT
10149 $(OBJDIR)/fcntl64.o: dietfeatures.h
10152 -# This facepalm brought to you by: Ubuntu!
10153 -$(OBJDIR)/stackgap.o: lib/stackgap.c dietfeatures.h
10154 - $(CROSS)$(CC) $(INC) $(CFLAGS) -c lib/stackgap.c -o $@ -D__dietlibc__ -fno-stack-protector
10155 - $(COMMENT) -$(CROSS)strip -x -R .comment -R .note $@
10158 $(OBJDIR)/strndup.o: dietfeatures.h
10160 +# dietdirent.h dependencies
10161 +$(OBJDIR)/closedir.o $(OBJDIR)/fdopendir.o $(OBJDIR)/ftw.o $(OBJDIR)/ftw64.o $(OBJDIR)/opendir.o $(OBJDIR)/readdir.o $(OBJDIR)/readdir64.o $(OBJDIR)/readdir_r.o $(OBJDIR)/rewinddir.o $(OBJDIR)/seekdir.o $(OBJDIR)/telldir.o $(OBJDIR)/dirfd.o: dietdirent.h
10163 +$(OBJDIR)/thrd_%.o: include/thread.h
10165 +$(OBJDIR)/__fcntl64.o $(OBJDIR)/__fstat64.o $(OBJDIR)/__fstatfs64.o $(OBJDIR)/__ftruncate64.o \
10166 +$(OBJDIR)/__getcwd.o $(OBJDIR)/__lstat64.o $(OBJDIR)/__mmap.o $(OBJDIR)/__ptrace.o \
10167 +$(OBJDIR)/__sendfile64.o $(OBJDIR)/__stat64.o $(OBJDIR)/__statfs64.o $(OBJDIR)/__stime.o \
10168 +$(OBJDIR)/__truncate64.o $(OBJDIR)/__utmp_io.o $(OBJDIR)/__v_printf.o $(OBJDIR)/addmntent.o \
10169 +$(OBJDIR)/alloc.o $(OBJDIR)/bindresvport.o $(OBJDIR)/cfsetispeed.o $(OBJDIR)/cfsetospeed.o \
10170 +$(OBJDIR)/clnt_generic.o $(OBJDIR)/clnt_tcp.o $(OBJDIR)/clnt_udp.o $(OBJDIR)/cnd_timedwait.o \
10171 +$(OBJDIR)/cnd_wait.o $(OBJDIR)/confstr.o $(OBJDIR)/dnscruft2.o $(OBJDIR)/dnsd.o \
10172 +$(OBJDIR)/err.o $(OBJDIR)/errno_location.o $(OBJDIR)/errx.o $(OBJDIR)/execl.o \
10173 +$(OBJDIR)/execle.o $(OBJDIR)/execlp.o $(OBJDIR)/execv.o $(OBJDIR)/execvp.o \
10174 +$(OBJDIR)/fdglue.o $(OBJDIR)/fdglue2.o $(OBJDIR)/fdopen.o $(OBJDIR)/freopen.o \
10175 +$(OBJDIR)/ftell.o $(OBJDIR)/fwrite.o $(OBJDIR)/getdelim.o $(OBJDIR)/gethostbyaddr.o \
10176 +$(OBJDIR)/gethostbyaddr_r.o $(OBJDIR)/gethostbyname.o $(OBJDIR)/gethostbyname2.o \
10177 +$(OBJDIR)/gethostbyname2_r.o $(OBJDIR)/gethostbyname_r.o $(OBJDIR)/gethostent.o \
10178 +$(OBJDIR)/getpass.o $(OBJDIR)/glob.o $(OBJDIR)/herrno_location.o $(OBJDIR)/iconv.o \
10179 +$(OBJDIR)/iconv_open.o $(OBJDIR)/inet_pton.o $(OBJDIR)/isatty.o $(OBJDIR)/lockf.o \
10180 +$(OBJDIR)/logging.o $(OBJDIR)/lseek64.o $(OBJDIR)/mbrlen.o $(OBJDIR)/mbrtowc.o \
10181 +$(OBJDIR)/mkdtemp.o $(OBJDIR)/mkstemp.o $(OBJDIR)/mktemp.o $(OBJDIR)/mmap64.o \
10182 +$(OBJDIR)/mtx_lock.o $(OBJDIR)/mtx_timedlock.o $(OBJDIR)/mtx_trylock.o \
10183 +$(OBJDIR)/mtx_unlock.o $(OBJDIR)/netent.o $(OBJDIR)/nice.o $(OBJDIR)/openpty.o \
10184 +$(OBJDIR)/perror.o $(OBJDIR)/pmap_getmaps.o $(OBJDIR)/pmap_rmt.o \
10185 +$(OBJDIR)/pthread_atfork.o $(OBJDIR)/pthread_attr_getdetachstate.o \
10186 +$(OBJDIR)/pthread_attr_getinheritsched.o $(OBJDIR)/pthread_attr_getschedparam.o \
10187 +$(OBJDIR)/pthread_attr_getschedpolicy.o $(OBJDIR)/pthread_attr_getscope.o \
10188 +$(OBJDIR)/pthread_attr_getstackaddr.o $(OBJDIR)/pthread_attr_getstacksize.o \
10189 +$(OBJDIR)/pthread_attr_setdetachstate.o $(OBJDIR)/pthread_attr_setinheritsched.o \
10190 +$(OBJDIR)/pthread_attr_setschedparam.o $(OBJDIR)/pthread_attr_setschedpolicy.o \
10191 +$(OBJDIR)/pthread_attr_setscope.o $(OBJDIR)/pthread_attr_setstackaddr.o \
10192 +$(OBJDIR)/pthread_attr_setstacksize.o $(OBJDIR)/pthread_cleanup.o \
10193 +$(OBJDIR)/pthread_cond_broadcast.o $(OBJDIR)/pthread_cond_destroy.o \
10194 +$(OBJDIR)/pthread_cond_init.o $(OBJDIR)/pthread_cond_signal.o \
10195 +$(OBJDIR)/pthread_cond_timedwait.o $(OBJDIR)/pthread_cond_wait.o \
10196 +$(OBJDIR)/pthread_condattr_getshared.o $(OBJDIR)/pthread_condattr_setshared.o \
10197 +$(OBJDIR)/pthread_create.o $(OBJDIR)/pthread_detach.o $(OBJDIR)/pthread_fdglue2.o \
10198 +$(OBJDIR)/pthread_internal.o $(OBJDIR)/pthread_join.o $(OBJDIR)/pthread_key.o \
10199 +$(OBJDIR)/pthread_mutex_destroy.o $(OBJDIR)/pthread_mutex_init.o \
10200 +$(OBJDIR)/pthread_mutex_lock.o $(OBJDIR)/pthread_mutex_trylock.o \
10201 +$(OBJDIR)/pthread_mutex_unlock.o $(OBJDIR)/pthread_mutexattr_getkind_np.o \
10202 +$(OBJDIR)/pthread_mutexattr_init.o $(OBJDIR)/pthread_mutexattr_setkind_np.o \
10203 +$(OBJDIR)/pthread_semaphore_destroy.o $(OBJDIR)/pthread_semaphore_getvalue.o \
10204 +$(OBJDIR)/pthread_semaphore_init.o $(OBJDIR)/pthread_semaphore_misc.o \
10205 +$(OBJDIR)/pthread_semaphore_post.o $(OBJDIR)/pthread_semaphore_trywait.o \
10206 +$(OBJDIR)/pthread_semaphore_wait.o $(OBJDIR)/pthread_setcancelstate.o \
10207 +$(OBJDIR)/pthread_setschedparam.o $(OBJDIR)/pthread_spinlock.o \
10208 +$(OBJDIR)/putenv.o $(OBJDIR)/putpwent.o $(OBJDIR)/readdir64.o \
10209 +$(OBJDIR)/realpath.o $(OBJDIR)/remove.o $(OBJDIR)/res_mkquery.o \
10210 +$(OBJDIR)/res_query.o $(OBJDIR)/res_search.o $(OBJDIR)/sigaddset.o \
10211 +$(OBJDIR)/sigdelset.o $(OBJDIR)/sigismember.o $(OBJDIR)/signalfd.o \
10212 +$(OBJDIR)/strerror.o $(OBJDIR)/strtol.o $(OBJDIR)/strtoll.o \
10213 +$(OBJDIR)/strtoul.o $(OBJDIR)/strtoull.o $(OBJDIR)/svc.o \
10214 +$(OBJDIR)/svc_run.o $(OBJDIR)/svc_tcp.o $(OBJDIR)/svc_udp.o \
10215 +$(OBJDIR)/sysconf.o $(OBJDIR)/sysconf_cpus.o $(OBJDIR)/system.o \
10216 +$(OBJDIR)/tcflow.o $(OBJDIR)/tcsendbreak.o $(OBJDIR)/tcsetattr.o \
10217 +$(OBJDIR)/tempnam.o $(OBJDIR)/thrd_exit.o $(OBJDIR)/thrd_join.o \
10218 +$(OBJDIR)/tmpnam.o $(OBJDIR)/utxent.o $(OBJDIR)/verr.o \
10219 +$(OBJDIR)/verrx.o $(OBJDIR)/vwarn.o $(OBJDIR)/warn.o \
10220 +$(OBJDIR)/wcsrtombs.o $(OBJDIR)/wcstombs.o: include/errno_definition.h
10222 +$(OBJDIR)/abort.o $(OBJDIR)/pselect.o $(OBJDIR)/__utmp_block_signals.o \
10223 +$(OBJDIR)/system.o $(OBJDIR)/utxent.o $(OBJDIR)/sigemptyset.o \
10224 +$(OBJDIR)/sigorset.o $(OBJDIR)/sigandset.o $(OBJDIR)/sigfillset.o \
10225 +$(OBJDIR)/sigisemptyset.o: include/signal.h
10227 +include/errno_definition.h: dietfeatures.h
10228 + if grep -q '^#define WANT_TLS' $<; then echo "extern __thread int errno;"; else echo "extern int errno;"; fi > $@
10231 + gcc -nostdlib -shared -g -DIN_LDSO -Iinclude.ldso -I. -isystem include x86_64/start.S -o ldso ldso.c -fPIC x86_64/dyn_syscalls.S lib/errno_location.c -D__thread=
10233 +GIT_CVSIMPORT=git cvsimport
10234 +CVS_EXTRA_bigo.ensc.de=;proxy=www-cache;proxyport=3128
10235 +CVS_EXTRA=$(CVS_EXTRA_$(shell hostname -d))
10237 + $(GIT_CVSIMPORT) -k -p '--cvs-direct' -d ':pserver$(CVS_EXTRA):cvs@cvs.fefe.de:/cvs' dietlibc
10238 diff -urN -x .git dietlibc-0.33/mips/Makefile.add dietlibc/mips/Makefile.add
10239 --- dietlibc-0.33/mips/Makefile.add 2012-01-24 18:24:27.000000000 +0000
10240 +++ dietlibc/mips/Makefile.add 2015-01-01 12:14:43.514938893 +0000
10242 ifeq ($(CROSS),mips-linux-)
10245 +ifeq ($(CC),gcc -mabi=64)
10246 +CFLAGS+=$(ENDIAN) -Os -march=mips64
10248 CFLAGS+=$(ENDIAN) -Os -march=mips2
10250 VPATH:=mips:syscalls.s:$(VPATH)
10251 LIBOBJ+=$(OBJDIR)/pread64.o $(OBJDIR)/pwrite64.o $(OBJDIR)/divdi3.o $(OBJDIR)/__CAS.o
10252 diff -urN -x .git dietlibc-0.33/mips/start.S dietlibc/mips/start.S
10253 --- dietlibc-0.33/mips/start.S 2006-05-29 16:30:53.000000000 +0000
10254 +++ dietlibc/mips/start.S 2015-01-01 12:14:43.514938893 +0000
10259 +#ifdef WANT_ELFINFO
10260 +# warning "MAKE ME MIPS CODE!"
10261 +1: addu $a2, $a2, 4 /* increment envp */
10262 + lw $4, -4($a2) /* load envp[-1]; TODO: is $4 a proper
10263 + temporary register? */
10264 + bnz 1b /* ... until envp[-1]==NULL
10265 + TODO: use proper 'bnz' operation */
10266 + sw $a2, __elfinfo
10271 diff -urN -x .git dietlibc-0.33/mips/syscalls.h dietlibc/mips/syscalls.h
10272 --- dietlibc-0.33/mips/syscalls.h 2008-12-10 20:00:59.000000000 +0000
10273 +++ dietlibc/mips/syscalls.h 2015-01-01 12:14:43.514938893 +0000
10275 * Linux o32 style syscalls are in the range from 4000 to 4999.
10277 #define __NR_Linux 4000
10278 -#define __NR_syscall (__NR_Linux + 0)
10279 -#define __NR_exit (__NR_Linux + 1)
10280 -#define __NR_fork (__NR_Linux + 2)
10281 -#define __NR_read (__NR_Linux + 3)
10282 -#define __NR_write (__NR_Linux + 4)
10283 -#define __NR_open (__NR_Linux + 5)
10284 -#define __NR_close (__NR_Linux + 6)
10285 -#define __NR_waitpid (__NR_Linux + 7)
10286 -#define __NR_creat (__NR_Linux + 8)
10287 -#define __NR_link (__NR_Linux + 9)
10288 +#define __NR_syscall (__NR_Linux + 0)
10289 +#define __NR_exit (__NR_Linux + 1)
10290 +#define __NR_fork (__NR_Linux + 2)
10291 +#define __NR_read (__NR_Linux + 3)
10292 +#define __NR_write (__NR_Linux + 4)
10293 +#define __NR_open (__NR_Linux + 5)
10294 +#define __NR_close (__NR_Linux + 6)
10295 +#define __NR_waitpid (__NR_Linux + 7)
10296 +#define __NR_creat (__NR_Linux + 8)
10297 +#define __NR_link (__NR_Linux + 9)
10298 #define __NR_unlink (__NR_Linux + 10)
10299 #define __NR_execve (__NR_Linux + 11)
10300 #define __NR_chdir (__NR_Linux + 12)
10301 @@ -203,8 +203,8 @@
10302 #define __NR_rt_sigtimedwait (__NR_Linux + 197)
10303 #define __NR_rt_sigqueueinfo (__NR_Linux + 198)
10304 #define __NR_rt_sigsuspend (__NR_Linux + 199)
10305 -#define __NR_pread (__NR_Linux + 200)
10306 -#define __NR_pwrite (__NR_Linux + 201)
10307 +#define __NR_pread64 (__NR_Linux + 200)
10308 +#define __NR_pwrite64 (__NR_Linux + 201)
10309 #define __NR_chown (__NR_Linux + 202)
10310 #define __NR_getcwd (__NR_Linux + 203)
10311 #define __NR_capget (__NR_Linux + 204)
10312 @@ -296,7 +296,7 @@
10313 #define __NR_mknodat (__NR_Linux + 290)
10314 #define __NR_fchownat (__NR_Linux + 291)
10315 #define __NR_futimesat (__NR_Linux + 292)
10316 -#define __NR_fstatat (__NR_Linux + 293)
10317 +#define __NR_fstatat64 (__NR_Linux + 293)
10318 #define __NR_unlinkat (__NR_Linux + 294)
10319 #define __NR_renameat (__NR_Linux + 295)
10320 #define __NR_linkat (__NR_Linux + 296)
10321 @@ -312,21 +312,53 @@
10322 #define __NR_tee (__NR_Linux + 306)
10323 #define __NR_vmsplice (__NR_Linux + 307)
10324 #define __NR_move_pages (__NR_Linux + 308)
10325 -#define __NR_set_robust_list (__NR_Linux + 272)
10326 -#define __NR_get_robust_list (__NR_Linux + 273)
10327 -#define __NR_kexec_load (__NR_Linux + 274)
10328 -#define __NR_getcpu (__NR_Linux + 275)
10329 -#define __NR_epoll_pwait (__NR_Linux + 276)
10330 -#define __NR_ioprio_set (__NR_Linux + 277)
10331 -#define __NR_ioprio_get (__NR_Linux + 278)
10332 -#define __NR_utimensat (__NR_Linux + 279)
10333 -#define __NR_signalfd (__NR_Linux + 280)
10334 -#define __NR_timerfd (__NR_Linux + 281)
10335 -#define __NR_eventfd (__NR_Linux + 282)
10336 -#define __NR_fallocate (__NR_Linux + 283)
10337 -#define __NR_timerfd_create (__NR_Linux + 284)
10338 -#define __NR_timerfd_gettime (__NR_Linux + 285)
10339 -#define __NR_timerfd_settime (__NR_Linux + 286)
10340 +#define __NR_set_robust_list (__NR_Linux + 309)
10341 +#define __NR_get_robust_list (__NR_Linux + 310)
10342 +#define __NR_kexec_load (__NR_Linux + 311)
10343 +#define __NR_getcpu (__NR_Linux + 312)
10344 +#define __NR_epoll_pwait (__NR_Linux + 313)
10345 +#define __NR_ioprio_set (__NR_Linux + 314)
10346 +#define __NR_ioprio_get (__NR_Linux + 315)
10347 +#define __NR_utimensat (__NR_Linux + 316)
10348 +#define __NR_signalfd (__NR_Linux + 317)
10349 +#define __NR_timerfd (__NR_Linux + 318)
10350 +#define __NR_eventfd (__NR_Linux + 319)
10351 +#define __NR_fallocate (__NR_Linux + 320)
10352 +#define __NR_timerfd_create (__NR_Linux + 321)
10353 +#define __NR_timerfd_gettime (__NR_Linux + 322)
10354 +#define __NR_timerfd_settime (__NR_Linux + 323)
10355 +#define __NR_signalfd4 (__NR_Linux + 324)
10356 +#define __NR_eventfd2 (__NR_Linux + 325)
10357 +#define __NR_epoll_create1 (__NR_Linux + 326)
10358 +#define __NR_dup3 (__NR_Linux + 327)
10359 +#define __NR_pipe2 (__NR_Linux + 328)
10360 +#define __NR_inotify_init1 (__NR_Linux + 329)
10361 +#define __NR_preadv (__NR_Linux + 330)
10362 +#define __NR_pwritev (__NR_Linux + 331)
10363 +#define __NR_rt_tgsigqueueinfo (__NR_Linux + 332)
10364 +#define __NR_perf_event_open (__NR_Linux + 333)
10365 +#define __NR_accept4 (__NR_Linux + 334)
10366 +#define __NR_recvmmsg (__NR_Linux + 335)
10367 +#define __NR_fanotify_init (__NR_Linux + 336)
10368 +#define __NR_fanotify_mark (__NR_Linux + 337)
10369 +#define __NR_prlimit64 (__NR_Linux + 338)
10370 +#define __NR_name_to_handle_at (__NR_Linux + 339)
10371 +#define __NR_open_by_handle_at (__NR_Linux + 340)
10372 +#define __NR_clock_adjtime (__NR_Linux + 341)
10373 +#define __NR_syncfs (__NR_Linux + 342)
10374 +#define __NR_sendmmsg (__NR_Linux + 343)
10375 +#define __NR_setns (__NR_Linux + 344)
10376 +#define __NR_process_vm_readv (__NR_Linux + 345)
10377 +#define __NR_process_vm_writev (__NR_Linux + 346)
10378 +#define __NR_kcmp (__NR_Linux + 347)
10379 +#define __NR_finit_module (__NR_Linux + 348)
10380 +#define __NR_sched_setattr (__NR_Linux + 349)
10381 +#define __NR_sched_getattr (__NR_Linux + 350)
10382 +#define __NR_renameat2 (__NR_Linux + 351)
10383 +#define __NR_seccomp (__NR_Linux + 352)
10384 +#define __NR_getrandom (__NR_Linux + 353)
10385 +#define __NR_memfd_create (__NR_Linux + 354)
10388 #define syscall_weak(name,wsym,sym) \
10390 diff -urN -x .git dietlibc-0.33/parisc/semctl.S dietlibc/parisc/semctl.S
10391 --- dietlibc-0.33/parisc/semctl.S 1970-01-01 00:00:00.000000000 +0000
10392 +++ dietlibc/parisc/semctl.S 2015-01-01 12:14:43.518272227 +0000
10394 +#include "syscalls.h"
10396 +syscall(semctl,semctl)
10397 diff -urN -x .git dietlibc-0.33/parisc/semget.S dietlibc/parisc/semget.S
10398 --- dietlibc-0.33/parisc/semget.S 1970-01-01 00:00:00.000000000 +0000
10399 +++ dietlibc/parisc/semget.S 2015-01-01 12:14:43.518272227 +0000
10401 +#include "syscalls.h"
10403 +syscall(semget,semget)
10404 diff -urN -x .git dietlibc-0.33/parisc/semop.S dietlibc/parisc/semop.S
10405 --- dietlibc-0.33/parisc/semop.S 1970-01-01 00:00:00.000000000 +0000
10406 +++ dietlibc/parisc/semop.S 2015-01-01 12:14:43.518272227 +0000
10408 +#include "syscalls.h"
10410 +syscall(semop,semop)
10411 diff -urN -x .git dietlibc-0.33/parisc/start.S dietlibc/parisc/start.S
10412 --- dietlibc-0.33/parisc/start.S 2006-05-29 16:30:53.000000000 +0000
10413 +++ dietlibc/parisc/start.S 2015-01-01 12:14:43.518272227 +0000
10415 ldil LP%environ, %r19
10416 ldo RP%environ(%r19), %r19
10418 +#ifdef WANT_ELFINFO
10419 +# warning "MAKE ME PARISC CODE!"
10420 +1: add %r20, %r19, %r19 ; envp += 4
10421 + ldw -4(0,%r19), %r21 ; load envp[-4] into %r21
10422 + comibf =,0, 0,%r21,1b ; compare %r21 with 0 without nullification
10424 + ldil LP%__elfinfo, %r19
10425 + ldo RP%__elfinfo(%r19), %r19
10428 /* Expand the stack to store the 5th through 7th args */
10431 diff -urN -x .git dietlibc-0.33/parisc/strcmp.S dietlibc/parisc/strcmp.S
10432 --- dietlibc-0.33/parisc/strcmp.S 2003-09-04 01:50:50.000000000 +0000
10433 +++ dietlibc/parisc/strcmp.S 2015-01-01 12:14:43.518272227 +0000
10443 diff -urN -x .git dietlibc-0.33/parisc/syscalls.h dietlibc/parisc/syscalls.h
10444 --- dietlibc-0.33/parisc/syscalls.h 2008-12-10 20:00:59.000000000 +0000
10445 +++ dietlibc/parisc/syscalls.h 2015-01-01 12:14:43.518272227 +0000
10446 @@ -323,8 +323,40 @@
10447 #define __NR_timerfd_create (__NR_Linux + 306)
10448 #define __NR_timerfd_settime (__NR_Linux + 307)
10449 #define __NR_timerfd_gettime (__NR_Linux + 308)
10450 +#define __NR_signalfd4 (__NR_Linux + 309)
10451 +#define __NR_eventfd2 (__NR_Linux + 310)
10452 +#define __NR_epoll_create1 (__NR_Linux + 311)
10453 +#define __NR_dup3 (__NR_Linux + 312)
10454 +#define __NR_pipe2 (__NR_Linux + 313)
10455 +#define __NR_inotify_init1 (__NR_Linux + 314)
10456 +#define __NR_preadv (__NR_Linux + 315)
10457 +#define __NR_pwritev (__NR_Linux + 316)
10458 +#define __NR_rt_tgsigqueueinfo (__NR_Linux + 317)
10459 +#define __NR_perf_event_open (__NR_Linux + 318)
10460 +#define __NR_recvmmsg (__NR_Linux + 319)
10461 +#define __NR_accept4 (__NR_Linux + 320)
10462 +#define __NR_prlimit64 (__NR_Linux + 321)
10463 +#define __NR_fanotify_init (__NR_Linux + 322)
10464 +#define __NR_fanotify_mark (__NR_Linux + 323)
10465 +#define __NR_clock_adjtime (__NR_Linux + 324)
10466 +#define __NR_name_to_handle_at (__NR_Linux + 325)
10467 +#define __NR_open_by_handle_at (__NR_Linux + 326)
10468 +#define __NR_syncfs (__NR_Linux + 327)
10469 +#define __NR_setns (__NR_Linux + 328)
10470 +#define __NR_sendmmsg (__NR_Linux + 329)
10471 +#define __NR_process_vm_readv (__NR_Linux + 330)
10472 +#define __NR_process_vm_writev (__NR_Linux + 331)
10473 +#define __NR_kcmp (__NR_Linux + 332)
10474 +#define __NR_finit_module (__NR_Linux + 333)
10475 +#define __NR_sched_setattr (__NR_Linux + 334)
10476 +#define __NR_sched_getattr (__NR_Linux + 335)
10477 +#define __NR_utimes (__NR_Linux + 336)
10478 +#define __NR_renameat2 (__NR_Linux + 337)
10479 +#define __NR_seccomp (__NR_Linux + 338)
10480 +#define __NR_getrandom (__NR_Linux + 339)
10481 +#define __NR_memfd_create (__NR_Linux + 340)
10483 -#define __NR_Linux_syscalls (__NR_fallocate + 1)
10484 +#define __NR_Linux_syscalls (__NR_memfd_create + 1)
10486 #define LINUX_GATEWAY_ADDR 0x100
10488 diff -urN -x .git dietlibc-0.33/PORTING dietlibc/PORTING
10489 --- dietlibc-0.33/PORTING 2010-09-25 17:03:25.000000000 +0000
10490 +++ dietlibc/PORTING 2015-01-01 12:14:43.451605563 +0000
10492 - edit include/sys/mman.h
10493 - edit include/sys/shm.h
10494 - edit include/sys/stat.h
10495 + - edit include/sys/tls.h
10496 - edit include/errno.h
10498 - edit include/termios.h
10499 + - edit lib/__get_cur_tcb.c
10500 - edit diet.c to make it recognize the architecture and add proper
10502 - edit libcompat/syscall.S
10503 diff -urN -x .git dietlibc-0.33/ppc/select.S dietlibc/ppc/select.S
10504 --- dietlibc-0.33/ppc/select.S 1970-01-01 00:00:00.000000000 +0000
10505 +++ dietlibc/ppc/select.S 2015-01-01 12:14:43.518272227 +0000
10507 +#include "syscalls.h"
10509 +syscall_weak(_newselect,select,__libc_select)
10510 diff -urN -x .git dietlibc-0.33/ppc/start.S dietlibc/ppc/start.S
10511 --- dietlibc-0.33/ppc/start.S 2006-05-29 16:30:53.000000000 +0000
10512 +++ dietlibc/ppc/start.S 2015-01-01 12:14:43.518272227 +0000
10515 stw 5,environ@l(14)
10517 +#ifdef WANT_ELFINFO
10523 + stw 5,__elfinfo@l(14)
10526 #ifdef WANT_DYNAMIC
10529 diff -urN -x .git dietlibc-0.33/ppc/syscalls.h dietlibc/ppc/syscalls.h
10530 --- dietlibc-0.33/ppc/syscalls.h 2008-12-10 20:00:59.000000000 +0000
10531 +++ dietlibc/ppc/syscalls.h 2015-01-01 12:14:43.518272227 +0000
10532 @@ -311,7 +311,54 @@
10533 #define __NR_subpage_prot 310
10534 #define __NR_timerfd_settime 311
10535 #define __NR_timerfd_gettime 312
10537 +#define __NR_signalfd4 313
10538 +#define __NR_eventfd2 314
10539 +#define __NR_epoll_create1 315
10540 +#define __NR_dup3 316
10541 +#define __NR_pipe2 317
10542 +#define __NR_inotify_init1 318
10543 +#define __NR_perf_event_open 319
10544 +#define __NR_preadv 320
10545 +#define __NR_pwritev 321
10546 +#define __NR_rt_tgsigqueueinfo 322
10547 +#define __NR_fanotify_init 323
10548 +#define __NR_fanotify_mark 324
10549 +#define __NR_prlimit64 325
10550 +#define __NR_socket 326
10551 +#define __NR_bind 327
10552 +#define __NR_connect 328
10553 +#define __NR_listen 329
10554 +#define __NR_accept 330
10555 +#define __NR_getsockname 331
10556 +#define __NR_getpeername 332
10557 +#define __NR_socketpair 333
10558 +#define __NR_send 334
10559 +#define __NR_sendto 335
10560 +#define __NR_recv 336
10561 +#define __NR_recvfrom 337
10562 +#define __NR_shutdown 338
10563 +#define __NR_setsockopt 339
10564 +#define __NR_getsockopt 340
10565 +#define __NR_sendmsg 341
10566 +#define __NR_recvmsg 342
10567 +#define __NR_recvmmsg 343
10568 +#define __NR_accept4 344
10569 +#define __NR_name_to_handle_at 345
10570 +#define __NR_open_by_handle_at 346
10571 +#define __NR_clock_adjtime 347
10572 +#define __NR_syncfs 348
10573 +#define __NR_sendmmsg 349
10574 +#define __NR_setns 350
10575 +#define __NR_process_vm_readv 351
10576 +#define __NR_process_vm_writev 352
10577 +#define __NR_finit_module 353
10578 +#define __NR_kcmp 354
10579 +#define __NR_sched_setattr 355
10580 +#define __NR_sched_getattr 356
10581 +#define __NR_renameat2 357
10582 +#define __NR_seccomp 358
10583 +#define __NR_getrandom 359
10584 +#define __NR_memfd_create 360
10586 #define syscall_weak(name,wsym,sym) \
10588 diff -urN -x .git dietlibc-0.33/ppc64/select.S dietlibc/ppc64/select.S
10589 --- dietlibc-0.33/ppc64/select.S 1970-01-01 00:00:00.000000000 +0000
10590 +++ dietlibc/ppc64/select.S 2015-01-01 12:14:43.521605560 +0000
10592 +#include "syscalls.h"
10594 +syscall_weak(_newselect,select,__libc_select)
10595 diff -urN -x .git dietlibc-0.33/ppc64/start.S dietlibc/ppc64/start.S
10596 --- dietlibc-0.33/ppc64/start.S 2012-01-24 18:24:28.000000000 +0000
10597 +++ dietlibc/ppc64/start.S 2015-01-01 12:14:43.521605560 +0000
10599 oris 14,14,environ@ha
10600 std 5,environ@l(14)
10602 +#ifdef WANT_ELFINFO
10608 + std 5,__elfinfo@l(14)
10611 #ifdef WANT_DYNAMIC
10612 /* #warning dynamic */
10614 diff -urN -x .git dietlibc-0.33/ppc64/syscalls.h dietlibc/ppc64/syscalls.h
10615 --- dietlibc-0.33/ppc64/syscalls.h 2008-12-10 20:00:59.000000000 +0000
10616 +++ dietlibc/ppc64/syscalls.h 2015-01-01 12:14:43.521605560 +0000
10617 @@ -311,7 +311,54 @@
10618 #define __NR_subpage_prot 310
10619 #define __NR_timerfd_settime 311
10620 #define __NR_timerfd_gettime 312
10622 +#define __NR_signalfd4 313
10623 +#define __NR_eventfd2 314
10624 +#define __NR_epoll_create1 315
10625 +#define __NR_dup3 316
10626 +#define __NR_pipe2 317
10627 +#define __NR_inotify_init1 318
10628 +#define __NR_perf_event_open 319
10629 +#define __NR_preadv 320
10630 +#define __NR_pwritev 321
10631 +#define __NR_rt_tgsigqueueinfo 322
10632 +#define __NR_fanotify_init 323
10633 +#define __NR_fanotify_mark 324
10634 +#define __NR_prlimit64 325
10635 +#define __NR_socket 326
10636 +#define __NR_bind 327
10637 +#define __NR_connect 328
10638 +#define __NR_listen 329
10639 +#define __NR_accept 330
10640 +#define __NR_getsockname 331
10641 +#define __NR_getpeername 332
10642 +#define __NR_socketpair 333
10643 +#define __NR_send 334
10644 +#define __NR_sendto 335
10645 +#define __NR_recv 336
10646 +#define __NR_recvfrom 337
10647 +#define __NR_shutdown 338
10648 +#define __NR_setsockopt 339
10649 +#define __NR_getsockopt 340
10650 +#define __NR_sendmsg 341
10651 +#define __NR_recvmsg 342
10652 +#define __NR_recvmmsg 343
10653 +#define __NR_accept4 344
10654 +#define __NR_name_to_handle_at 345
10655 +#define __NR_open_by_handle_at 346
10656 +#define __NR_clock_adjtime 347
10657 +#define __NR_syncfs 348
10658 +#define __NR_sendmmsg 349
10659 +#define __NR_setns 350
10660 +#define __NR_process_vm_readv 351
10661 +#define __NR_process_vm_writev 352
10662 +#define __NR_finit_module 353
10663 +#define __NR_kcmp 354
10664 +#define __NR_sched_setattr 355
10665 +#define __NR_sched_getattr 356
10666 +#define __NR_renameat2 357
10667 +#define __NR_seccomp 358
10668 +#define __NR_getrandom 359
10669 +#define __NR_memfd_create 360
10671 #define __diet_proto_common(sym) \
10672 .section ".opd","aw"; \
10673 diff -urN -x .git dietlibc-0.33/s390/fadvise64_64.S dietlibc/s390/fadvise64_64.S
10674 --- dietlibc-0.33/s390/fadvise64_64.S 1970-01-01 00:00:00.000000000 +0000
10675 +++ dietlibc/s390/fadvise64_64.S 2015-01-01 12:14:43.521605560 +0000
10677 +#include "syscalls.h"
10679 +#ifdef __NR_fadvise64_64
10680 +syscall(fadvise64_64, __s390_fadvise64_64);
10682 diff -urN -x .git dietlibc-0.33/s390/__fadvise.c dietlibc/s390/__fadvise.c
10683 --- dietlibc-0.33/s390/__fadvise.c 1970-01-01 00:00:00.000000000 +0000
10684 +++ dietlibc/s390/__fadvise.c 2015-01-01 12:14:43.521605560 +0000
10686 +#include "syscalls.h"
10688 +#define _LINUX_SOURCE
10689 +#include <fcntl.h>
10690 +#include <unistd.h>
10692 +struct fadvise64_64_layout
10700 +long fadvise64_64(int fd, off64_t offset, off64_t len, int advise)
10702 + struct fadvise64_64_layout parameters;
10703 + extern long __s390_fadvise64_64(struct fadvise64_64_layout *args);
10705 + parameters.fd = fd;
10706 + parameters.offset = offset;
10707 + parameters.len = len;
10708 + parameters.advise = advise;
10710 + return __s390_fadvise64_64(¶meters);
10713 +int posix_fadvise(int fd, off64_t offset, off64_t len, int advise)
10714 + __attribute__((__alias__("fadvise64_64")));
10715 diff -urN -x .git dietlibc-0.33/s390/Makefile.add dietlibc/s390/Makefile.add
10716 --- dietlibc-0.33/s390/Makefile.add 2002-11-09 18:10:23.000000000 +0000
10717 +++ dietlibc/s390/Makefile.add 2015-01-01 12:14:43.521605560 +0000
10720 CFLAGS+=-Os # -fomit-frame-pointer -fstrict-aliasing
10721 VPATH:=s390:syscalls.s:$(VPATH)
10722 -LIBOBJ+=$(OBJDIR)/__waitpid.o
10723 +LIBOBJ+=$(OBJDIR)/__waitpid.o $(OBJDIR)/__fadvise.o
10724 diff -urN -x .git dietlibc-0.33/s390/setjmp.S dietlibc/s390/setjmp.S
10725 --- dietlibc-0.33/s390/setjmp.S 2001-11-26 14:50:08.000000000 +0000
10726 +++ dietlibc/s390/setjmp.S 2015-01-01 12:14:43.521605560 +0000
10730 .type _setjmp,@function
10733 .size _setjmp,.-_setjmp
10735 @@ -26,15 +27,18 @@
10738 /* Make a tail call to __sigjmp_save; it takes the same args. */
10742 -.L0: la %r1,.L1-.L0(0,%r1)
10743 +.L0: al %r1,.L1-.L0(0,%r1)
10744 l %r1,__sigjmp_save@GOT12(0,%r1)
10746 +.L0: l %r1,.L1-.L0(0,%r1)
10751 .L1: .long _GLOBAL_OFFSET_TABLE_-.L0
10755 .L1: .long __sigjmp_save
10757 .size __sigsetjmp,.-__sigsetjmp;
10758 diff -urN -x .git dietlibc-0.33/s390/start.S dietlibc/s390/start.S
10759 --- dietlibc-0.33/s390/start.S 2006-05-29 16:30:53.000000000 +0000
10760 +++ dietlibc/s390/start.S 2015-01-01 12:14:43.521605560 +0000
10765 +#ifdef WANT_ELFINFO
10767 +1: ahi %r4, 4 # increment envp
10768 + l %r12, 0(%r6,%r4) # load envp[-1] into %r12
10769 + or %r12, %r12 # test %r12 for NULL
10776 /* call main or _dyn_start */
10779 diff -urN -x .git dietlibc-0.33/s390/syscalls.h dietlibc/s390/syscalls.h
10780 --- dietlibc-0.33/s390/syscalls.h 2008-12-10 20:00:59.000000000 +0000
10781 +++ dietlibc/s390/syscalls.h 2015-01-01 12:14:43.521605560 +0000
10782 @@ -277,6 +277,7 @@
10783 #define __NR_mknodat 290
10784 #define __NR_fchownat 291
10785 #define __NR_futimesat 292
10786 +#define __NR_fstatat64 293
10787 #define __NR_unlinkat 294
10788 #define __NR_renameat 295
10789 #define __NR_linkat 296
10790 @@ -305,7 +306,35 @@
10791 #define __NR_timerfd_create 319
10792 #define __NR_timerfd_settime 320
10793 #define __NR_timerfd_gettime 321
10795 +#define __NR_signalfd4 322
10796 +#define __NR_eventfd2 323
10797 +#define __NR_inotify_init1 324
10798 +#define __NR_pipe2 325
10799 +#define __NR_dup3 326
10800 +#define __NR_epoll_create1 327
10801 +#define __NR_preadv 328
10802 +#define __NR_pwritev 329
10803 +#define __NR_rt_tgsigqueueinfo 330
10804 +#define __NR_perf_event_open 331
10805 +#define __NR_fanotify_init 332
10806 +#define __NR_fanotify_mark 333
10807 +#define __NR_prlimit64 334
10808 +#define __NR_name_to_handle_at 335
10809 +#define __NR_open_by_handle_at 336
10810 +#define __NR_clock_adjtime 337
10811 +#define __NR_syncfs 338
10812 +#define __NR_setns 339
10813 +#define __NR_process_vm_readv 340
10814 +#define __NR_process_vm_writev 341
10815 +#define __NR_s390_runtime_instr 342
10816 +#define __NR_kcmp 343
10817 +#define __NR_finit_module 344
10818 +#define __NR_sched_setattr 345
10819 +#define __NR_sched_getattr 346
10820 +#define __NR_renameat2 347
10821 +#define __NR_seccomp 348
10822 +#define __NR_getrandom 349
10823 +#define __NR_memfd_create 350
10825 #define syscall_weak(name,wsym,sym) \
10827 diff -urN -x .git dietlibc-0.33/s390x/setjmp.S dietlibc/s390x/setjmp.S
10828 --- dietlibc-0.33/s390x/setjmp.S 2003-10-10 13:37:34.000000000 +0000
10829 +++ dietlibc/s390x/setjmp.S 2015-01-01 12:14:43.521605560 +0000
10833 .type _setjmp,@function
10836 .size _setjmp,.-_setjmp
10838 @@ -26,15 +27,18 @@
10841 /* Make a tail call to __sigjmp_save; it takes the same args. */
10845 -.L0: la %r1,.L1-.L0(0,%r1)
10846 +.L0: al %r1,.L1-.L0(0,%r1)
10847 l %r1,__sigjmp_save@GOT12(0,%r1)
10849 +.L0: l %r1,.L1-.L0(0,%r1)
10854 .L1: .long _GLOBAL_OFFSET_TABLE_-.L0
10858 .L1: .long __sigjmp_save
10860 .size __sigsetjmp,.-__sigsetjmp;
10861 diff -urN -x .git dietlibc-0.33/s390x/start.S dietlibc/s390x/start.S
10862 --- dietlibc-0.33/s390x/start.S 2006-05-29 16:30:54.000000000 +0000
10863 +++ dietlibc/s390x/start.S 2015-01-01 12:14:43.521605560 +0000
10868 +#ifdef WANT_ELFINFO
10869 +1: aghi %r4, 8 # increment envp
10870 + lg %r12, -8(0,%r4) # load envp[-1] into %r12
10871 + ogr %r12, %r12 # test %r12 for NULL
10878 /* call main or _dyn_start */
10879 #ifdef WANT_DYNAMIC
10880 brasl %r14,_dyn_start
10881 diff -urN -x .git dietlibc-0.33/s390x/syscalls.h dietlibc/s390x/syscalls.h
10882 --- dietlibc-0.33/s390x/syscalls.h 2008-12-10 20:00:59.000000000 +0000
10883 +++ dietlibc/s390x/syscalls.h 2015-01-01 12:14:43.521605560 +0000
10884 @@ -305,7 +305,35 @@
10885 #define __NR_timerfd_create 319
10886 #define __NR_timerfd_settime 320
10887 #define __NR_timerfd_gettime 321
10889 +#define __NR_signalfd4 322
10890 +#define __NR_eventfd2 323
10891 +#define __NR_inotify_init1 324
10892 +#define __NR_pipe2 325
10893 +#define __NR_dup3 326
10894 +#define __NR_epoll_create1 327
10895 +#define __NR_preadv 328
10896 +#define __NR_pwritev 329
10897 +#define __NR_rt_tgsigqueueinfo 330
10898 +#define __NR_perf_event_open 331
10899 +#define __NR_fanotify_init 332
10900 +#define __NR_fanotify_mark 333
10901 +#define __NR_prlimit64 334
10902 +#define __NR_name_to_handle_at 335
10903 +#define __NR_open_by_handle_at 336
10904 +#define __NR_clock_adjtime 337
10905 +#define __NR_syncfs 338
10906 +#define __NR_setns 339
10907 +#define __NR_process_vm_readv 340
10908 +#define __NR_process_vm_writev 341
10909 +#define __NR_s390_runtime_instr 342
10910 +#define __NR_kcmp 343
10911 +#define __NR_finit_module 344
10912 +#define __NR_sched_setattr 345
10913 +#define __NR_sched_getattr 346
10914 +#define __NR_renameat2 347
10915 +#define __NR_seccomp 348
10916 +#define __NR_getrandom 349
10917 +#define __NR_memfd_create 350
10920 * There are some system calls that are not present on 64 bit, some
10921 @@ -313,6 +341,7 @@
10922 * is __NR_chown on 64 bit).
10929 diff -urN -x .git dietlibc-0.33/sparc/shmat.c dietlibc/sparc/shmat.c
10930 --- dietlibc-0.33/sparc/shmat.c 2001-06-16 17:48:57.000000000 +0000
10931 +++ dietlibc/sparc/shmat.c 2015-01-01 12:14:43.521605560 +0000
10933 #include <sys/shm.h>
10934 #include <unistd.h>
10936 -extern void* __ipc();
10937 +#include "../dietpagesize.h"
10940 -#define PAGE_SIZE 4096
10942 +extern void* __ipc();
10944 void* shmat(int shmid,const void* shmaddr,int shmflg) {
10946 register void* result;
10947 result=__ipc(SHMAT,shmid,shmflg,&raddr,shmaddr);
10948 - if ((unsigned long)result <= -(unsigned long)PAGE_SIZE)
10949 + if ((unsigned long)result <= -(unsigned long)__DIET_PAGE_SIZE)
10953 diff -urN -x .git dietlibc-0.33/sparc/start.S dietlibc/sparc/start.S
10954 --- dietlibc-0.33/sparc/start.S 2006-05-29 16:30:54.000000000 +0000
10955 +++ dietlibc/sparc/start.S 2015-01-01 12:14:43.521605560 +0000
10957 or %o3, %lo(environ), %o3
10960 +#ifdef WANT_ELFINFO
10961 +# warning "VERIFY ME!"
10962 +1: add %o2, %o2, 4
10964 + orcc %o4, %o4, %o4
10971 /* When starting a binary via the dynamic linker, %g1 contains the
10972 address of the shared library termination function, which will be
10973 registered with atexit(). If we are statically linked, this will
10974 diff -urN -x .git dietlibc-0.33/sparc/strchr.S dietlibc/sparc/strchr.S
10975 --- dietlibc-0.33/sparc/strchr.S 2003-09-04 01:50:50.000000000 +0000
10976 +++ dietlibc/sparc/strchr.S 2015-01-01 12:14:43.521605560 +0000
10986 diff -urN -x .git dietlibc-0.33/sparc/strcmp.S dietlibc/sparc/strcmp.S
10987 --- dietlibc-0.33/sparc/strcmp.S 2003-09-04 01:50:50.000000000 +0000
10988 +++ dietlibc/sparc/strcmp.S 2015-01-01 12:14:43.521605560 +0000
10998 diff -urN -x .git dietlibc-0.33/sparc/syscalls.h dietlibc/sparc/syscalls.h
10999 --- dietlibc-0.33/sparc/syscalls.h 2008-12-10 20:00:59.000000000 +0000
11000 +++ dietlibc/sparc/syscalls.h 2015-01-01 12:14:43.521605560 +0000
11001 @@ -315,6 +315,38 @@
11002 #define __NR_fallocate 314
11003 #define __NR_timerfd_settime 315
11004 #define __NR_timerfd_gettime 316
11005 +#define __NR_signalfd4 317
11006 +#define __NR_eventfd2 318
11007 +#define __NR_epoll_create1 319
11008 +#define __NR_dup3 320
11009 +#define __NR_pipe2 321
11010 +#define __NR_inotify_init1 322
11011 +#define __NR_accept4 323
11012 +#define __NR_preadv 324
11013 +#define __NR_pwritev 325
11014 +#define __NR_rt_tgsigqueueinfo 326
11015 +#define __NR_perf_event_open 327
11016 +#define __NR_recvmmsg 328
11017 +#define __NR_fanotify_init 329
11018 +#define __NR_fanotify_mark 330
11019 +#define __NR_prlimit64 331
11020 +#define __NR_name_to_handle_at 332
11021 +#define __NR_open_by_handle_at 333
11022 +#define __NR_clock_adjtime 334
11023 +#define __NR_syncfs 335
11024 +#define __NR_sendmmsg 336
11025 +#define __NR_setns 337
11026 +#define __NR_process_vm_readv 338
11027 +#define __NR_process_vm_writev 339
11028 +#define __NR_kern_features 340
11029 +#define __NR_kcmp 341
11030 +#define __NR_finit_module 342
11031 +#define __NR_sched_setattr 343
11032 +#define __NR_sched_getattr 344
11033 +#define __NR_renameat2 345
11034 +#define __NR_seccomp 346
11035 +#define __NR_getrandom 347
11036 +#define __NR_memfd_create 348
11038 #define syscall_weak(name,wsym,sym) \
11040 diff -urN -x .git dietlibc-0.33/sparc64/start.S dietlibc/sparc64/start.S
11041 --- dietlibc-0.33/sparc64/start.S 2006-05-29 16:30:54.000000000 +0000
11042 +++ dietlibc/sparc64/start.S 2015-01-01 12:14:43.524938894 +0000
11044 or %o3, %lo(environ), %o3
11047 +#ifdef WANT_ELFINFO
11048 +# warning "VERIFY ME!"
11049 +1: add %o2, %o2, 8
11051 + orcc %o4, %o4, %o4
11058 /* When starting a binary via the dynamic linker, %g1 contains the
11059 address of the shared library termination function, which will be
11060 registered with atexit(). If we are statically linked, this will
11061 diff -urN -x .git dietlibc-0.33/sparc64/syscalls.h dietlibc/sparc64/syscalls.h
11062 --- dietlibc-0.33/sparc64/syscalls.h 2008-12-10 20:00:59.000000000 +0000
11063 +++ dietlibc/sparc64/syscalls.h 2015-01-01 12:14:43.524938894 +0000
11064 @@ -314,6 +314,38 @@
11065 #define __NR_fallocate 314
11066 #define __NR_timerfd_settime 315
11067 #define __NR_timerfd_gettime 316
11068 +#define __NR_signalfd4 317
11069 +#define __NR_eventfd2 318
11070 +#define __NR_epoll_create1 319
11071 +#define __NR_dup3 320
11072 +#define __NR_pipe2 321
11073 +#define __NR_inotify_init1 322
11074 +#define __NR_accept4 323
11075 +#define __NR_preadv 324
11076 +#define __NR_pwritev 325
11077 +#define __NR_rt_tgsigqueueinfo 326
11078 +#define __NR_perf_event_open 327
11079 +#define __NR_recvmmsg 328
11080 +#define __NR_fanotify_init 329
11081 +#define __NR_fanotify_mark 330
11082 +#define __NR_prlimit64 331
11083 +#define __NR_name_to_handle_at 332
11084 +#define __NR_open_by_handle_at 333
11085 +#define __NR_clock_adjtime 334
11086 +#define __NR_syncfs 335
11087 +#define __NR_sendmmsg 336
11088 +#define __NR_setns 337
11089 +#define __NR_process_vm_readv 338
11090 +#define __NR_process_vm_writev 339
11091 +#define __NR_kern_features 340
11092 +#define __NR_kcmp 341
11093 +#define __NR_finit_module 342
11094 +#define __NR_sched_setattr 343
11095 +#define __NR_sched_getattr 344
11096 +#define __NR_renameat2 345
11097 +#define __NR_seccomp 346
11098 +#define __NR_getrandom 347
11099 +#define __NR_memfd_create 348
11101 #define syscall_weak(name,wsym,sym) \
11103 diff -urN -x .git dietlibc-0.33/syscalls.h dietlibc/syscalls.h
11104 --- dietlibc-0.33/syscalls.h 2005-05-08 15:33:38.000000000 +0000
11105 +++ dietlibc/syscalls.h 2015-01-01 12:14:43.524938894 +0000
11107 #include "i386/syscalls.h"
11109 #elif defined(__x86_64__)
11110 +#if defined(__ILP32__)
11111 +#include "x32/syscalls.h"
11113 #include "x86_64/syscalls.h"
11116 #elif defined(__sparc__)
11117 #if defined(__arch64__)
11118 diff -urN -x .git dietlibc-0.33/syscalls.s/accept4.S dietlibc/syscalls.s/accept4.S
11119 --- dietlibc-0.33/syscalls.s/accept4.S 1970-01-01 00:00:00.000000000 +0000
11120 +++ dietlibc/syscalls.s/accept4.S 2015-01-01 12:14:43.524938894 +0000
11122 +#include "syscalls.h"
11124 +#ifdef __NR_accept4
11125 +syscall(accept4,accept4)
11127 diff -urN -x .git dietlibc-0.33/syscalls.s/dup3.S dietlibc/syscalls.s/dup3.S
11128 --- dietlibc-0.33/syscalls.s/dup3.S 1970-01-01 00:00:00.000000000 +0000
11129 +++ dietlibc/syscalls.s/dup3.S 2015-01-01 12:14:43.524938894 +0000
11131 +#include "syscalls.h"
11133 +syscall(dup3,dup3)
11134 diff -urN -x .git dietlibc-0.33/syscalls.s/environ.S dietlibc/syscalls.s/environ.S
11135 --- dietlibc-0.33/syscalls.s/environ.S 2005-01-31 12:53:34.000000000 +0000
11136 +++ dietlibc/syscalls.s/environ.S 2015-01-01 12:14:43.524938894 +0000
11140 #include <endian.h>
11141 +#include <dietfeatures.h>
11143 .type environ,object
11147 .size environ,.-environ
11148 .size __environ,.-__environ
11150 +/* __elfinfo will be initialized in start.S to point to the
11151 + terminating NULL of the environment. */
11153 +#ifdef WANT_ELFINFO
11154 +.type __elfinfo,object
11157 +#if __WORDSIZE == 64
11162 +.size __elfinfo,.-__elfinfo
11164 diff -urN -x .git dietlibc-0.33/syscalls.s/epoll_create1.S dietlibc/syscalls.s/epoll_create1.S
11165 --- dietlibc-0.33/syscalls.s/epoll_create1.S 1970-01-01 00:00:00.000000000 +0000
11166 +++ dietlibc/syscalls.s/epoll_create1.S 2015-01-01 12:14:43.524938894 +0000
11168 +#include "syscalls.h"
11170 +#ifdef __NR_epoll_create1
11171 +syscall(epoll_create1,epoll_create1)
11173 diff -urN -x .git dietlibc-0.33/syscalls.s/errno.S dietlibc/syscalls.s/errno.S
11174 --- dietlibc-0.33/syscalls.s/errno.S 2002-11-15 15:39:17.000000000 +0000
11175 +++ dietlibc/syscalls.s/errno.S 1970-01-01 00:00:00.000000000 +0000
11180 -.type errno,object
11184 -.size errno,.-errno
11185 diff -urN -x .git dietlibc-0.33/syscalls.s/__eventfd2.S dietlibc/syscalls.s/__eventfd2.S
11186 --- dietlibc-0.33/syscalls.s/__eventfd2.S 1970-01-01 00:00:00.000000000 +0000
11187 +++ dietlibc/syscalls.s/__eventfd2.S 2015-01-01 12:14:43.524938894 +0000
11189 +#include "syscalls.h"
11191 +syscall(eventfd2,__eventfd2)
11192 diff -urN -x .git dietlibc-0.33/syscalls.s/__eventfd.S dietlibc/syscalls.s/__eventfd.S
11193 --- dietlibc-0.33/syscalls.s/__eventfd.S 1970-01-01 00:00:00.000000000 +0000
11194 +++ dietlibc/syscalls.s/__eventfd.S 2015-01-01 12:14:43.524938894 +0000
11196 +#include "syscalls.h"
11198 +syscall(eventfd,__eventfd)
11199 diff -urN -x .git dietlibc-0.33/syscalls.s/fadvise64.S dietlibc/syscalls.s/fadvise64.S
11200 --- dietlibc-0.33/syscalls.s/fadvise64.S 2012-01-24 18:24:28.000000000 +0000
11201 +++ dietlibc/syscalls.s/fadvise64.S 2015-01-01 12:14:43.524938894 +0000
11204 #include "syscalls.h"
11206 +#ifdef __NR_fadvise64
11207 +syscall(fadvise64,fadvise64)
11209 #ifndef __NR_fadvise64_64
11210 +posix_fadvise = fadvise64
11211 .globl posix_fadvise
11212 -.type posix_fadvise,@function
11216 -#ifdef __NR_fadvise64
11217 -syscall(fadvise64,fadvise64)
11222 diff -urN -x .git dietlibc-0.33/syscalls.s/fanotify_init.S dietlibc/syscalls.s/fanotify_init.S
11223 --- dietlibc-0.33/syscalls.s/fanotify_init.S 1970-01-01 00:00:00.000000000 +0000
11224 +++ dietlibc/syscalls.s/fanotify_init.S 2015-01-01 12:14:43.524938894 +0000
11226 +#include "syscalls.h"
11228 +syscall(fanotify_init,fanotify_init)
11229 diff -urN -x .git dietlibc-0.33/syscalls.s/fanotify_mark.S dietlibc/syscalls.s/fanotify_mark.S
11230 --- dietlibc-0.33/syscalls.s/fanotify_mark.S 1970-01-01 00:00:00.000000000 +0000
11231 +++ dietlibc/syscalls.s/fanotify_mark.S 2015-01-01 12:14:43.524938894 +0000
11233 +#include "syscalls.h"
11235 +syscall(fanotify_mark,fanotify_mark)
11236 diff -urN -x .git dietlibc-0.33/syscalls.s/fstatat64.S dietlibc/syscalls.s/fstatat64.S
11237 --- dietlibc-0.33/syscalls.s/fstatat64.S 1970-01-01 00:00:00.000000000 +0000
11238 +++ dietlibc/syscalls.s/fstatat64.S 2015-01-01 12:14:43.524938894 +0000
11240 +#include "syscalls.h"
11242 +#ifdef __NR_fstatat64
11243 +syscall(fstatat64,fstatat64)
11245 diff -urN -x .git dietlibc-0.33/syscalls.s/fstatat.S dietlibc/syscalls.s/fstatat.S
11246 --- dietlibc-0.33/syscalls.s/fstatat.S 1970-01-01 00:00:00.000000000 +0000
11247 +++ dietlibc/syscalls.s/fstatat.S 2015-01-01 12:14:43.524938894 +0000
11249 +#include "syscalls.h"
11251 +#ifdef __NR_fstatat
11252 +syscall(fstatat,fstatat)
11254 diff -urN -x .git dietlibc-0.33/syscalls.s/getrandom.S dietlibc/syscalls.s/getrandom.S
11255 --- dietlibc-0.33/syscalls.s/getrandom.S 1970-01-01 00:00:00.000000000 +0000
11256 +++ dietlibc/syscalls.s/getrandom.S 2015-01-01 12:14:43.528272226 +0000
11258 +#include "syscalls.h"
11260 +syscall(getrandom,getrandom)
11261 diff -urN -x .git dietlibc-0.33/syscalls.s/inotify_init1.S dietlibc/syscalls.s/inotify_init1.S
11262 --- dietlibc-0.33/syscalls.s/inotify_init1.S 1970-01-01 00:00:00.000000000 +0000
11263 +++ dietlibc/syscalls.s/inotify_init1.S 2015-01-01 12:14:43.528272226 +0000
11265 +#include "syscalls.h"
11267 +#ifdef __NR_inotify_init1
11268 +syscall(inotify_init1,inotify_init1)
11270 diff -urN -x .git dietlibc-0.33/syscalls.s/_llseek.S dietlibc/syscalls.s/_llseek.S
11271 --- dietlibc-0.33/syscalls.s/_llseek.S 2004-06-30 05:52:31.000000000 +0000
11272 +++ dietlibc/syscalls.s/_llseek.S 2015-01-01 12:14:43.524938894 +0000
11275 #ifdef __NR__llseek
11277 -.type llseek,function
11278 +.type llseek,STT_FUNC
11280 syscall(_llseek,_llseek)
11282 diff -urN -x .git dietlibc-0.33/syscalls.s/memfd_create.S dietlibc/syscalls.s/memfd_create.S
11283 --- dietlibc-0.33/syscalls.s/memfd_create.S 1970-01-01 00:00:00.000000000 +0000
11284 +++ dietlibc/syscalls.s/memfd_create.S 2015-01-01 12:14:43.528272226 +0000
11286 +#include "syscalls.h"
11288 +syscall(memfd_create,memfd_create)
11289 diff -urN -x .git dietlibc-0.33/syscalls.s/newfstatat.S dietlibc/syscalls.s/newfstatat.S
11290 --- dietlibc-0.33/syscalls.s/newfstatat.S 2012-01-16 21:10:29.000000000 +0000
11291 +++ dietlibc/syscalls.s/newfstatat.S 2015-01-01 12:14:43.528272226 +0000
11294 #ifdef __NR_newfstatat
11295 syscall(newfstatat,newfstatat)
11297 +#ifdef __NR_fstatat64
11298 +# error __NR_newfstatat and __NR_fstatat64 must not both be defined
11301 +fstatat = newfstatat
11305 diff -urN -x .git dietlibc-0.33/syscalls.s/pipe2.S dietlibc/syscalls.s/pipe2.S
11306 --- dietlibc-0.33/syscalls.s/pipe2.S 1970-01-01 00:00:00.000000000 +0000
11307 +++ dietlibc/syscalls.s/pipe2.S 2015-01-01 12:14:43.528272226 +0000
11309 +#include "syscalls.h"
11311 +syscall(pipe2,pipe2)
11312 diff -urN -x .git dietlibc-0.33/syscalls.s/preadv.S dietlibc/syscalls.s/preadv.S
11313 --- dietlibc-0.33/syscalls.s/preadv.S 1970-01-01 00:00:00.000000000 +0000
11314 +++ dietlibc/syscalls.s/preadv.S 2015-01-01 12:14:43.528272226 +0000
11316 +#include "syscalls.h"
11318 +syscall(preadv,preadv)
11319 diff -urN -x .git dietlibc-0.33/syscalls.s/pwritev.S dietlibc/syscalls.s/pwritev.S
11320 --- dietlibc-0.33/syscalls.s/pwritev.S 1970-01-01 00:00:00.000000000 +0000
11321 +++ dietlibc/syscalls.s/pwritev.S 2015-01-01 12:14:43.528272226 +0000
11323 +#include "syscalls.h"
11325 +syscall(pwritev,pwritev)
11326 diff -urN -x .git dietlibc-0.33/syscalls.s/recvmmsg.S dietlibc/syscalls.s/recvmmsg.S
11327 --- dietlibc-0.33/syscalls.s/recvmmsg.S 1970-01-01 00:00:00.000000000 +0000
11328 +++ dietlibc/syscalls.s/recvmmsg.S 2015-01-01 12:14:43.528272226 +0000
11330 +#include "syscalls.h"
11332 +#ifdef __NR_recvmmsg
11333 +syscall(recvmmsg,recvmmsg)
11335 diff -urN -x .git dietlibc-0.33/syscalls.s/sendmmsg.S dietlibc/syscalls.s/sendmmsg.S
11336 --- dietlibc-0.33/syscalls.s/sendmmsg.S 1970-01-01 00:00:00.000000000 +0000
11337 +++ dietlibc/syscalls.s/sendmmsg.S 2015-01-01 12:14:43.528272226 +0000
11339 +#include "syscalls.h"
11341 +#ifdef __NR_sendmmsg
11342 +syscall(sendmmsg,sendmmsg)
11344 diff -urN -x .git dietlibc-0.33/syscalls.s/setns.S dietlibc/syscalls.s/setns.S
11345 --- dietlibc-0.33/syscalls.s/setns.S 1970-01-01 00:00:00.000000000 +0000
11346 +++ dietlibc/syscalls.s/setns.S 2015-01-01 12:14:43.528272226 +0000
11348 +#include "syscalls.h"
11350 +syscall(setns,setns)
11351 diff -urN -x .git dietlibc-0.33/syscalls.s/__signalfd4.S dietlibc/syscalls.s/__signalfd4.S
11352 --- dietlibc-0.33/syscalls.s/__signalfd4.S 1970-01-01 00:00:00.000000000 +0000
11353 +++ dietlibc/syscalls.s/__signalfd4.S 2015-01-01 12:14:43.524938894 +0000
11355 +#include "syscalls.h"
11357 +#ifdef __NR_signalfd
11358 +syscall(signalfd4,__signalfd4)
11360 diff -urN -x .git dietlibc-0.33/syscalls.s/syncfs.S dietlibc/syscalls.s/syncfs.S
11361 --- dietlibc-0.33/syscalls.s/syncfs.S 1970-01-01 00:00:00.000000000 +0000
11362 +++ dietlibc/syscalls.s/syncfs.S 2015-01-01 12:14:43.531605560 +0000
11364 +#include "syscalls.h"
11366 +syscall(syncfs,syncfs)
11367 diff -urN -x .git dietlibc-0.33/syscalls.s/timerfd_gettime.S dietlibc/syscalls.s/timerfd_gettime.S
11368 --- dietlibc-0.33/syscalls.s/timerfd_gettime.S 1970-01-01 00:00:00.000000000 +0000
11369 +++ dietlibc/syscalls.s/timerfd_gettime.S 2015-01-01 12:14:43.531605560 +0000
11371 +#include "syscalls.h"
11373 +syscall(timerfd_gettime,timerfd_gettime)
11374 diff -urN -x .git dietlibc-0.33/syscalls.s/timerfd_settime.S dietlibc/syscalls.s/timerfd_settime.S
11375 --- dietlibc-0.33/syscalls.s/timerfd_settime.S 1970-01-01 00:00:00.000000000 +0000
11376 +++ dietlibc/syscalls.s/timerfd_settime.S 2015-01-01 12:14:43.531605560 +0000
11378 +#include "syscalls.h"
11380 +syscall(timerfd_settime,timerfd_settime)
11381 diff -urN -x .git dietlibc-0.33/t.c dietlibc/t.c
11382 --- dietlibc-0.33/t.c 2010-09-25 17:03:25.000000000 +0000
11383 +++ dietlibc/t.c 2015-01-01 12:14:43.531605560 +0000
11386 #include <sys/statfs.h>
11387 #include <mqueue.h>
11388 +#include <ucontext.h>
11389 #ifdef __dietlibc__
11391 #include <write12.h>
11392 @@ -108,12 +109,27 @@
11393 #define malloc(x) ({typeof(x) y=x; (y<0 || (size_t)(y)!=y ? 0 : malloc(y));})
11395 int main(int argc,char *argv[]) {
11397 + struct ucontext uc;
11400 + puts("getcontext returned");
11404 + puts("should not get here");
11410 char* a=malloc(-3);
11411 char* b=malloc(0xffffffffull+1);
11412 printf("%p %p\n",a,b);
11415 printf("%u\n",getpagesize());
11420 @@ -172,7 +188,7 @@
11421 strcpy(buf+i,"/bin:/bin");
11424 - printf("%d\n",islower('ü'));
11425 + printf("%d\n",islower(0xfc));
11429 diff -urN -x .git dietlibc-0.33/test/adjtime.c dietlibc/test/adjtime.c
11430 --- dietlibc-0.33/test/adjtime.c 2002-08-05 18:08:24.000000000 +0000
11431 +++ dietlibc/test/adjtime.c 2015-01-01 12:14:43.531605560 +0000
11434 +#include <assert.h>
11435 +#include <errno.h>
11436 #include <sys/time.h>
11439 struct timeval a,b;
11441 a.tv_sec=0; a.tv_usec=0;
11442 - printf("%d\n",adjtime(&a,&b));
11443 + rc = adjtime(&a,&b);
11444 + assert(!rc || errno == EPERM);
11446 + rc = adjtime(&a, NULL);
11447 + assert(!rc || errno == EPERM);
11449 + rc = adjtime(NULL,&b);
11451 + assert(b.tv_sec < 30); /* 30 seconds delta is very unlikely... */
11452 + assert(b.tv_sec > -30); /* 30 seconds delta is very unlikely... */
11453 + assert(b.tv_usec > -1000000);
11454 + assert(b.tv_usec < 1000000);
11456 + printf("%lu/%d\n", (unsigned long)b.tv_sec, (int)b.tv_usec);
11459 diff -urN -x .git dietlibc-0.33/test/asctime.c dietlibc/test/asctime.c
11460 --- dietlibc-0.33/test/asctime.c 1970-01-01 00:00:00.000000000 +0000
11461 +++ dietlibc/test/asctime.c 2015-01-01 12:14:43.531605560 +0000
11463 +#include <assert.h>
11464 +#include <stdlib.h>
11470 + struct tm const tm = {
11480 + buf = malloc(4096);
11481 + assert(buf != NULL);
11482 + memset(buf, 23, 4096);
11484 + res = asctime_r(&tm, buf);
11485 + assert(strcmp(res, asctime(&tm)) == 0);
11486 + assert(strcmp(res, "Sun Dec 10 22:21:20 2012\n") == 0);
11488 + return EXIT_SUCCESS;
11490 diff -urN -x .git dietlibc-0.33/test/asprintf.c dietlibc/test/asprintf.c
11491 --- dietlibc-0.33/test/asprintf.c 2003-12-15 13:07:42.000000000 +0000
11492 +++ dietlibc/test/asprintf.c 2015-01-01 12:14:43.531605560 +0000
11494 assert(strlen(path) == asprintlen);
11496 printf("%s\n", path);
11497 - asprintlen=asprintf(&path, "/proc" "/%d/stat", strlen(argv[1]));
11498 + asprintlen=asprintf(&path, "/proc" "/%zu/stat", strlen(argv[1]));
11499 assert(strlen(path) == asprintlen);
11500 printf("%s\n", path);
11502 diff -urN -x .git dietlibc-0.33/test/atexit.c dietlibc/test/atexit.c
11503 --- dietlibc-0.33/test/atexit.c 2003-02-20 15:57:12.000000000 +0000
11504 +++ dietlibc/test/atexit.c 2015-01-01 12:14:43.531605560 +0000
11506 #include <unistd.h>
11509 - write(2,"atexit\n",7);
11510 + write(1,"atexit\n",7);
11514 diff -urN -x .git dietlibc-0.33/test/atfile.c dietlibc/test/atfile.c
11515 --- dietlibc-0.33/test/atfile.c 1970-01-01 00:00:00.000000000 +0000
11516 +++ dietlibc/test/atfile.c 2015-01-01 12:14:43.531605560 +0000
11518 +#define _GNU_SOURCE
11519 +#define _XOPEN_SOURCE 700
11520 +#define _FILE_OFFSET_BITS 64
11522 +#include <stdlib.h>
11523 +#include <fcntl.h>
11524 +#include <errno.h>
11525 +#include <assert.h>
11526 +#include <stdio.h>
11527 +#include <sys/stat.h>
11529 +#define TMPDIR "/tmp"
11531 +#define TEST(_op) do { \
11532 + int rc = (_op); \
11534 + printf("%s:%u: %s: %u/%s\n", __FILE__, __LINE__, \
11535 + # _op, errno, strerror(errno)); \
11540 +#define memeq(_a, _b) \
11541 + ((memcmp(_a, _b, sizeof *(_a)) == 0 ? 0 : -1))
11543 +#define memne(_a, _b) \
11544 + ((memcmp(_a, _b, sizeof *(_a)) == 0 ? -1 : 0))
11548 + char dname_buf[] = "/tmp/test-mmap.XXXXXX";
11552 + struct stat st[5];
11554 + /* check whether *at(2) syscalls are available */
11555 + dir_fd = openat(AT_FDCWD, "/", O_DIRECTORY|O_RDONLY);
11556 + if (dir_fd == -1 && errno == ENOSYS)
11557 + return EXIT_SUCCESS; /* kernel too old */
11559 + assert(dir_fd != -1);
11562 + /* create a tree like
11568 + * +- some-link -> some-file
11570 + dname = mkdtemp(dname_buf);
11571 + assert(dname != NULL);
11573 + dir_fd = open(dname, O_DIRECTORY|O_RDONLY);
11574 + assert(dir_fd != -1);
11576 + TEST(mkdirat(dir_fd, "test", 0700));
11577 + TEST(chdir(dname));
11578 + TEST(chdir("test"));
11580 + file_fd = openat(dir_fd, "some-file", O_WRONLY|O_CREAT, 0400);
11581 + assert(file_fd != -1);
11583 + write(file_fd, "some text\n", 10);
11584 + TEST(close(file_fd));
11586 + TEST(symlinkat("some-file", dir_fd, "some-link"));
11587 + TEST(symlinkat("dangling", dir_fd, "dangling-link"));
11589 + /* now check, whether attributes of 'some-file' and 'some-link'
11590 + * returned by stat(2), lstat(2) and fstatat(2) are consistent */
11591 + TEST(stat("../some-file", &st[0]));
11592 + TEST(lstat("../some-link", &st[1]));
11594 + TEST(fstatat(dir_fd, "some-file", &st[2], 0));
11595 + TEST(fstatat(dir_fd, "some-link", &st[3], AT_SYMLINK_NOFOLLOW));
11596 + TEST(fstatat(dir_fd, "some-link", &st[4], 0));
11598 + TEST(faccessat(dir_fd, "some-file", R_OK, 0));
11599 + TEST((faccessat(dir_fd, "some-file", W_OK, 0) == -1 &&
11600 + errno == EACCES) ? 0 : -1);;
11603 + fputs("skipping faccessat(..., AT_SYMLINK_NOFOLLOW) checks for now...\n",
11606 + /* this is broken for dietlibc; the 'flags' parameter is not checked
11607 + * by the kernel but must be handled by the libc itself */
11608 + TEST(faccessat(dir_fd, "some-link", W_OK, AT_SYMLINK_NOFOLLOW));
11609 + TEST(faccessat(dir_fd, "dangling-link", R_OK, AT_SYMLINK_NOFOLLOW));
11612 + assert(st[0].st_mode == (0400 | S_IFREG));
11613 + assert(S_ISLNK(st[1].st_mode));
11615 + TEST(memne(&st[0], &st[1]));
11616 + TEST(memeq(&st[0], &st[2]));
11617 + TEST(memeq(&st[0], &st[4]));
11618 + TEST(memeq(&st[1], &st[3]));
11620 + /* and cleanup the mess... */
11621 + TEST(unlinkat(dir_fd, "some-link", 0));
11622 + TEST(unlinkat(dir_fd, "some-file", 0));
11623 + TEST(unlinkat(dir_fd, "dangling-link", 0));
11624 + TEST(unlinkat(dir_fd, "test", AT_REMOVEDIR));
11625 + TEST(rmdir(dname));
11627 + return EXIT_SUCCESS;
11629 diff -urN -x .git dietlibc-0.33/test/byteswap.c dietlibc/test/byteswap.c
11630 --- dietlibc-0.33/test/byteswap.c 2003-12-15 13:07:42.000000000 +0000
11631 +++ dietlibc/test/byteswap.c 2015-01-01 12:14:43.531605560 +0000
11633 snprintf(buf,100,"%x %x", bswap_16(0x1234), bswap_16(0x5678));
11634 assert(strcmp(buf, "3412 7856") == 0);
11636 - printf("%lx\n",bswap_32(0x12345678));
11637 - snprintf(buf,100,"%lx", bswap_32(0x12345678));
11638 + printf("%x\n",(unsigned int)bswap_32(0x12345678));
11639 + snprintf(buf,100,"%x", (unsigned int)bswap_32(0x12345678));
11640 assert(strcmp(buf, "78563412") == 0);
11642 - printf("%qx\n",bswap_64(0x123456789ABCDEFull));
11643 - snprintf(buf,100,"%qx", bswap_64(0x123456789ABCDEFull));
11644 + printf("%llx\n",(unsigned long long)bswap_64(0x123456789ABCDEFull));
11645 + snprintf(buf,100,"%llx", (unsigned long long)bswap_64(0x123456789ABCDEFull));
11646 assert(strcmp(buf, "efcdab8967452301") == 0);
11649 diff -urN -x .git dietlibc-0.33/test/cycles.c dietlibc/test/cycles.c
11650 --- dietlibc-0.33/test/cycles.c 2004-08-27 15:09:14.000000000 +0000
11651 +++ dietlibc/test/cycles.c 2015-01-01 12:14:43.531605560 +0000
11653 asm volatile ("rdtsc" : "=a" (l), "=d" (h)); \
11654 dst = (((uint64_t)h) << 32) | l; \
11656 +#elif defined (__powerpc64__)
11657 +#define RDTSC(dst) asm volatile ("mftb %0" : "=r" (dst))
11658 +#elif defined (__powerpc__)
11659 +#define RDTSC(dst) do { \
11660 + uint32_t chk, tbl, tbu; \
11661 + /* The code below is as suggested in Motorola reference manual for 32 bits PPCs. */ \
11662 + __asm__ __volatile__ ("1: mftbu %0; mftb %1; mftbu %2; cmpw %2,%0; bne 1b" \
11663 + : "=r" (tbu), "=r" (tbl), "=r" (chk) ); \
11664 + dst = ((uint64_t)tbu << 32) | tbl; \
11666 +#elif defined (__sparcv9__)
11667 +#define RDTSC(dst) asm volatile ("rd %%tick, %%0":"=r"(dst))
11669 -#error "Unimplemented rdtsc"
11670 +#warning "Unimplemented rdtsc"
11671 +#define RDTSC(dst) dst = 0
11674 extern char **environ;
11676 if (!fork()) { execve(argv[1],argv+1,environ); exit(1); }
11679 - printf("%llu cycles\n",b-a);
11680 + printf("%llu cycles\n",(unsigned long long)(b-a));
11684 diff -urN -x .git dietlibc-0.33/test/dirent/.gitignore dietlibc/test/dirent/.gitignore
11685 --- dietlibc-0.33/test/dirent/.gitignore 1970-01-01 00:00:00.000000000 +0000
11686 +++ dietlibc/test/dirent/.gitignore 2015-01-01 12:14:43.531605560 +0000
11690 diff -urN -x .git dietlibc-0.33/test/ftruncate.c dietlibc/test/ftruncate.c
11691 --- dietlibc-0.33/test/ftruncate.c 1970-01-01 00:00:00.000000000 +0000
11692 +++ dietlibc/test/ftruncate.c 2015-01-01 12:14:43.531605560 +0000
11694 +#define _GNU_SOURCE
11695 +#define _XOPEN_SOURCE 600
11696 +#define _FILE_OFFSET_BITS 64
11698 +#include <stdlib.h>
11699 +#include <fcntl.h>
11700 +#include <assert.h>
11701 +#include <unistd.h>
11702 +#include <sys/stat.h>
11704 +#define CHECK(_sz) \
11705 + assert(ftruncate(fd, (_sz)) == 0); \
11706 + assert(fstat(fd, &st) == 0); \
11707 + assert(st.st_size == (_sz)); \
11709 +#define CHECK64(_sz) \
11710 + assert(ftruncate64(fd, (_sz)) == 0); \
11711 + assert(fstat64(fd, &st64) == 0); \
11712 + assert(st64.st_size == (_sz)); \
11716 + char file[] = "/tmp/dietlibc-fadvise-test.XXXXXX";
11720 + fd = mkstemp(file);
11723 + assert(ftruncate(fd, 500000) == 0);
11724 + assert(fstat(fd, &st) == 0);
11726 + if (st.st_blocks > 1) {
11727 + /* spare files not supported by filesystem :( */
11728 + return EXIT_SUCCESS;
11732 + CHECK(0x7fffffff);
11734 +#if __WORDSIZE == 32
11736 + struct stat64 st64;
11738 + CHECK64(0x7fffffff);
11739 + CHECK64(0x80000001ul);
11740 + CHECK64(0x17fffffffull);
11743 + CHECK(0x17fffffffull);
11746 + return EXIT_SUCCESS;
11748 diff -urN -x .git dietlibc-0.33/test/getmntent.c dietlibc/test/getmntent.c
11749 --- dietlibc-0.33/test/getmntent.c 2003-12-15 13:07:42.000000000 +0000
11750 +++ dietlibc/test/getmntent.c 2015-01-01 12:14:43.534938894 +0000
11753 printf("closing /etc/fstab\n");
11754 assert ( 1 == endmntent(fstab));
11755 - printf("closing /etc/fstab again\n");
11756 - assert ( 1 == endmntent(fstab)); /* endmntent must always return 1 */
11757 - printf("entmntent(0)\n");
11758 - assert ( 1 == endmntent(0)); /* causes a segfault with diet libc */
11763 diff -urN -x .git dietlibc-0.33/test/getservbyname.c dietlibc/test/getservbyname.c
11764 --- dietlibc-0.33/test/getservbyname.c 2003-12-15 13:07:42.000000000 +0000
11765 +++ dietlibc/test/getservbyname.c 2015-01-01 12:14:43.534938894 +0000
11769 +#include <arpa/inet.h>
11771 int main(int argc,char *argv[]) {
11772 struct servent* se;
11773 diff -urN -x .git dietlibc-0.33/test/.gitignore dietlibc/test/.gitignore
11774 --- dietlibc-0.33/test/.gitignore 1970-01-01 00:00:00.000000000 +0000
11775 +++ dietlibc/test/.gitignore 2015-01-01 12:14:43.531605560 +0000
11868 diff -urN -x .git dietlibc-0.33/test/if_nameindex.c dietlibc/test/if_nameindex.c
11869 --- dietlibc-0.33/test/if_nameindex.c 2003-02-20 15:57:12.000000000 +0000
11870 +++ dietlibc/test/if_nameindex.c 2015-01-01 12:14:43.534938894 +0000
11873 +#include <assert.h>
11874 #include <net/if.h>
11877 struct if_nameindex* t=if_nameindex();
11879 + assert(t != NULL);
11882 struct if_nameindex* t1=t;
11883 while (t->if_index) {
11884 diff -urN -x .git dietlibc-0.33/test/inet/.gitignore dietlibc/test/inet/.gitignore
11885 --- dietlibc-0.33/test/inet/.gitignore 1970-01-01 00:00:00.000000000 +0000
11886 +++ dietlibc/test/inet/.gitignore 2015-01-01 12:14:43.534938894 +0000
11891 diff -urN -x .git dietlibc-0.33/test/Makefile dietlibc/test/Makefile
11892 --- dietlibc-0.33/test/Makefile 2012-01-24 18:24:29.000000000 +0000
11893 +++ dietlibc/test/Makefile 2015-01-01 12:14:43.531605560 +0000
11898 -TESTPROGRAMS=adjtime alarm argv asprintf atexit bsearch byteswap calloc confstr cycles empty fadvise flush fnmatch \
11899 -fputc ftw fwrite getaddrinfo getenv getgrnam gethostbyaddr gethostbyname \
11900 +TESTPROGRAMS=adjtime alarm argv asctime asprintf atexit atfile bsearch byteswap calloc confstr cycles empty fadvise flush fnmatch \
11901 +fputc ftruncate ftw fwrite getaddrinfo getenv getgrnam gethostbyaddr gethostbyname \
11902 gethostbyname_r getmntent getopt getpass getpwnam getservbyname getservbyport getusershell \
11903 -glob grent hasmntopt hello iconv if_nameindex ltostr malloc-debugger md5_testharness \
11904 +glob grent hasmntopt hello iconv if_nameindex ltostr malloc-debugger math md5_testharness \
11905 memccpy memchr memcmp memrchr memusage mktime mmap_test pipe printf printftest \
11906 -protoent prototypes putenv pwent rand48 read1 readdir regex select sendfile servent siglist \
11907 -speed spent sprintf sscanf stdarg strcasecmp strcmp strncat strncpy strptime strrchr \
11908 -strstr strtol sysenter ungetc utime waitpid
11909 +protoent prototypes putenv pwent rand48 read1 readdir readdir64 regex select sendfile servent setjmp siglist \
11910 +sigsetjmp speed spent sprintf sscanf stdarg strcasecmp strcmp strncat strncpy strptime strrchr \
11911 +strstr strtol sysconf sysenter unaligned ungetc utime waitpid
11913 test: $(TESTPROGRAMS)
11915 diff -urN -x .git dietlibc-0.33/test/malloc-debugger.c dietlibc/test/malloc-debugger.c
11916 --- dietlibc-0.33/test/malloc-debugger.c 2003-02-20 15:57:13.000000000 +0000
11917 +++ dietlibc/test/malloc-debugger.c 2015-01-01 12:14:43.534938894 +0000
11920 char* c=malloc(13);
11922 - fprintf(stderr,"got %p\n",c);
11923 + fprintf(stdout,"got %p\n",c);
11926 tmp=realloc(c,12345);
11927 diff -urN -x .git dietlibc-0.33/test/math.c dietlibc/test/math.c
11928 --- dietlibc-0.33/test/math.c 1970-01-01 00:00:00.000000000 +0000
11929 +++ dietlibc/test/math.c 2015-01-01 12:14:43.534938894 +0000
11932 +#include <float.h>
11933 +#include <assert.h>
11937 + extern int __isinf(double d);
11938 + extern int __isnan(double d);
11940 +#if (__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3))
11941 + assert(__isinf(__builtin_inff()) == +1);
11942 + assert(__isinf(-__builtin_inff()) == -1);
11944 + assert(__isinf(__builtin_inf()) == +1);
11945 + assert(__isinf(-__builtin_inf()) == -1);
11947 + assert(__isnan(__builtin_nan("")));
11950 + assert(__isinf((DBL_MAX * DBL_MAX)) == +1);
11951 + assert(__isinf(-(DBL_MAX * DBL_MAX)) == -1);
11953 + assert(isinf((DBL_MAX * DBL_MAX)));
11954 + assert(isinf(-(DBL_MAX * DBL_MAX)));
11956 + //assert(isnan(nan("")));
11960 diff -urN -x .git dietlibc-0.33/test/mktime.c dietlibc/test/mktime.c
11961 --- dietlibc-0.33/test/mktime.c 2004-03-27 00:47:00.000000000 +0000
11962 +++ dietlibc/test/mktime.c 2015-01-01 12:14:43.534938894 +0000
11967 - printf("%d\n",mktime(&t));
11968 + printf("%ld\n",(long)mktime(&t));
11972 - printf("%d\n",mktime(&t));
11973 + printf("%ld\n",(long)mktime(&t));
11977 - printf("%d\n",mktime(&t));
11978 + printf("%ld\n",(long)mktime(&t));
11982 diff -urN -x .git dietlibc-0.33/test/mmap_test.c dietlibc/test/mmap_test.c
11983 --- dietlibc-0.33/test/mmap_test.c 2002-02-18 00:37:31.000000000 +0000
11984 +++ dietlibc/test/mmap_test.c 2015-01-01 12:14:43.534938894 +0000
11989 #include <unistd.h>
11990 +#include <stdlib.h>
11991 +#include <string.h>
11992 #include <sys/mman.h>
11995 -#define FILENAME "/tmp/zz_temp_mmap_test"
11996 -#define TESTSTRING "This is a test string"
11997 +#define TESTSTRING0 "This is a test string"
11998 +#define TESTSTRING1 "Another string for testing"
12001 int main (int argc, char * argv[])
12002 @@ -14,16 +15,26 @@
12004 void *filememory_1;
12005 void *filememory_2;
12007 - fd = open (FILENAME, O_RDWR | O_CREAT);
12009 + void *filememory_3;
12010 + unsigned int pg_sz = sysconf(_SC_PAGESIZE);
12011 + char fname[] = "/tmp/test-mmap.XXXXXX";
12013 + fd = mkstemp(fname);
12016 - fprintf (stderr, "Couldn't open %s for writing\n", FILENAME);
12017 + fprintf (stderr, "Couldn't open %s for writing\n", fname);
12021 - write (fd, TESTSTRING, sizeof(TESTSTRING));
12024 + write (fd, TESTSTRING0, sizeof TESTSTRING0);
12026 + ftruncate(fd, pg_sz);
12027 + lseek(fd, pg_sz, SEEK_SET);
12028 + write(fd, TESTSTRING1, sizeof TESTSTRING1);
12030 + ftruncate(fd, 2*pg_sz);
12033 Try mmapping the newly created file...
12038 + Test mapping at a given offset
12041 + filememory_3 = mmap (NULL, 0x0100, PROT_READ, MAP_PRIVATE, fd, pg_sz);
12043 + if (filememory_3 == (void *) -1)
12045 + perror("mmap (pg_sz) returned error");
12050 Try mmapping with a bogus file descriptor... (should fail)
12053 @@ -49,32 +72,33 @@
12060 Check that we can read back from the file OK
12063 - if ((*(unsigned char *) filememory_1) != TESTSTRING[0])
12064 + if (memcmp(filememory_1, TESTSTRING0, sizeof TESTSTRING0) != 0)
12066 fprintf (stderr, "mmap doesn't give expected data...\n");
12071 - fixme: check unmapping as well.... ??
12074 + if (memcmp(filememory_3, TESTSTRING1, sizeof TESTSTRING1) != 0)
12076 + fprintf (stderr, "mmap (pg_sz) doesn't give expected data...\n");
12080 + if (munmap(filememory_3, 0x0100) < 0 ||
12081 + munmap(filememory_1, 0x0100) < 0)
12083 + perror("munmap()");
12091 - if (unlink (FILENAME) != 0)
12093 - fprintf (stderr, "Unexpected problem deleting the tempfile... ?\n");
12100 diff -urN -x .git dietlibc-0.33/test/pipe.c dietlibc/test/pipe.c
12101 --- dietlibc-0.33/test/pipe.c 2002-05-13 15:56:48.000000000 +0000
12102 +++ dietlibc/test/pipe.c 2015-01-01 12:14:43.534938894 +0000
12110 assert (!pipe (fd));
12111 /* if for some reason the parent process has fd3 or fd4
12112 already open, then this will fail although there is
12113 diff -urN -x .git dietlibc-0.33/test/printf.c dietlibc/test/printf.c
12114 --- dietlibc-0.33/test/printf.c 2008-05-06 17:18:35.000000000 +0000
12115 +++ dietlibc/test/printf.c 2015-01-01 12:14:43.534938894 +0000
12117 #include <string.h>
12118 #include <stdlib.h>
12119 #include <assert.h>
12121 +#include <float.h>
12122 #include <sys/param.h>
12123 #include <locale.h>
12128 +# if (__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3))
12129 +# define INFINITY (__builtin_inf())
12134 +# if (__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3))
12135 +# define NAN (__builtin_nan(""))
12140 // https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=112986
12144 TEST_SNPRINTF(EXP, 0, __VA_ARGS__); \
12145 TEST_SNPRINTF(EXP, sizeof(EXP)+ALGN, __VA_ARGS__); \
12146 TEST_SNPRINTF_NULL(EXP, __VA_ARGS__)
12152 @@ -101,7 +116,7 @@
12153 TEST("42.23", "%5.2f", 42.23);
12154 TEST("42.23", "%5.4g", 42.23);
12155 TEST(" 42.2", "%5.3g", 42.23);
12158 TEST(" 1", "%*i", 4, 1);
12159 TEST(" 1", "%4i", 1);
12160 TEST("1 ", "%-4i", 1);
12161 @@ -131,13 +146,32 @@
12162 TEST("-01234", "%6.5i", -1234);
12163 TEST(" 1234", "%6.5s", "1234");
12166 + TEST("inf", "%f", INFINITY);
12167 + TEST("-inf", "%f", -INFINITY);
12168 + TEST("INF", "%F", INFINITY);
12169 + TEST("-INF", "%F", -INFINITY);
12171 + TEST("inf", "%g", INFINITY);
12172 + TEST("-inf", "%g", -INFINITY);
12173 + TEST("INF", "%G", INFINITY);
12174 + TEST("-INF", "%G", -INFINITY);
12178 + TEST("nan", "%f", NAN);
12179 + TEST("NAN", "%F", NAN);
12180 + TEST("nan", "%g", NAN);
12181 + TEST("NAN", "%G", NAN);
12185 setlocale(LC_ALL, "de_DE");
12188 TEST("1.234", "%'u", 1234);
12189 TEST("2 1", "%2$u %1$u", 1, 2);
12195 return EXIT_SUCCESS;
12197 diff -urN -x .git dietlibc-0.33/test/printftest.c dietlibc/test/printftest.c
12198 --- dietlibc-0.33/test/printftest.c 2003-12-15 13:07:42.000000000 +0000
12199 +++ dietlibc/test/printftest.c 2015-01-01 12:14:43.534938894 +0000
12200 @@ -101,8 +101,8 @@
12201 printf("#%i#\n",18);
12202 printf("#%d#\n",18);
12203 printf("#%u#\n",18);
12204 - printf("#%lu#\n",18);
12205 - printf("#%li#\n",18);
12206 + printf("#%lu#\n",18l);
12207 + printf("#%li#\n",18l);
12208 printf("#%-+#06d#\n", -123);
12209 printf("#%-+#6d#\n", -123);
12210 printf("#%+#06d#\n", -123);
12211 @@ -142,7 +142,7 @@
12213 memset(buf2,0,sizeof(buf));
12214 i=snprintf(buf2, 256, "%.9999u", 10);
12215 - printf("%i %i\n",i,strlen(buf2));
12216 + printf("%i %li\n",i,strlen(buf2));
12218 printf ("snprintf (\"%%.999999u\", 10) == %d\n",
12219 snprintf(buf2, sizeof(buf2), "%.999999u", 10));
12220 diff -urN -x .git dietlibc-0.33/test/rand48.c dietlibc/test/rand48.c
12221 --- dietlibc-0.33/test/rand48.c 2002-05-29 13:20:40.000000000 +0000
12222 +++ dietlibc/test/rand48.c 2015-01-01 12:14:43.534938894 +0000
12225 static unsigned short data[7] = { 1, 2, 3, 4, 5, 6, 7 };
12227 - printf ("one %X\n", mrand48 ());
12228 - printf ("two %X\n", mrand48 ());
12229 - printf ("three %X\n", mrand48 ());
12230 + printf ("one %lX\n", mrand48 ());
12231 + printf ("two %lX\n", mrand48 ());
12232 + printf ("three %lX\n", mrand48 ());
12235 printf ("after lcong48:\n");
12237 - printf ("one %X\n", mrand48 ());
12238 - printf ("two %X\n", mrand48 ());
12239 - printf ("three %X\n", mrand48 ());
12240 + printf ("one %lX\n", mrand48 ());
12241 + printf ("two %lX\n", mrand48 ());
12242 + printf ("three %lX\n", mrand48 ());
12246 diff -urN -x .git dietlibc-0.33/test/readdir64.c dietlibc/test/readdir64.c
12247 --- dietlibc-0.33/test/readdir64.c 1970-01-01 00:00:00.000000000 +0000
12248 +++ dietlibc/test/readdir64.c 2015-01-01 12:14:43.534938894 +0000
12250 +#define _FILE_OFFSET_BITS 64
12251 +#include "readdir.c"
12252 diff -urN -x .git dietlibc-0.33/test/readdir.c dietlibc/test/readdir.c
12253 --- dietlibc-0.33/test/readdir.c 2003-02-20 15:57:13.000000000 +0000
12254 +++ dietlibc/test/readdir.c 2015-01-01 12:14:43.534938894 +0000
12256 -#define _FILE_OFFSET_BITS 64
12257 +#define _BSD_SOURCE
12258 #include <dirent.h>
12260 +#include <stdlib.h>
12262 +#include <fcntl.h>
12264 +#include "../dietdirent.h"
12266 +static int rc = 0;
12268 +static void xputs(char const *str)
12270 + fputs(str, stderr);
12274 +static int create_file(char const *dir, char const *name)
12276 + char buf[strlen(dir) + strlen(name) + sizeof("/")];
12277 + strcpy(buf, dir);
12278 + strcat(buf, "/");
12279 + strcat(buf, name);
12281 + return close(open(buf, O_WRONLY|O_CREAT,0666));
12284 +static int remove_file(char const *dir, char const *name)
12286 + char buf[strlen(dir) + strlen(name) + sizeof("/")];
12287 + strcpy(buf, dir);
12288 + strcat(buf, "/");
12289 + strcat(buf, name);
12291 + return unlink(buf);
12295 - DIR* D=opendir(".");
12296 - struct dirent* d;
12297 + char tmpdir[] = "/tmp/readdir.XXXXXX";
12298 + unsigned long res = 0;
12300 + if (!mkdtemp(tmpdir)) {
12301 + perror("mkdtemp");
12304 + D=opendir(tmpdir);
12311 + if (chdir(tmpdir) < 0) {
12316 + close(open("bar",O_WRONLY|O_CREAT,0666));
12317 + close(open("baz",O_WRONLY|O_CREAT,0666));
12319 + struct dirent* d;
12321 while ((d=readdir(D))) {
12322 - printf("found %s\n",d->d_name);
12325 + if (strcmp(d->d_name,".") == 0)
12327 + else if (strcmp(d->d_name,"..") == 0)
12329 + else if (strcmp(d->d_name,"bar") == 0)
12331 + else if (strcmp(d->d_name,"baz") == 0)
12334 + xputs("got additional file");
12336 + if (lstat(d->d_name, &st) < 0) {
12339 + } else if (st.st_ino != d->d_ino) {
12340 + xputs("mismatch in ino");
12341 + } else if (d->d_type == DT_UNKNOWN) {
12343 + } else if ((d->d_type == DT_REG && !S_ISREG(st.st_mode)) ||
12344 + (d->d_type == DT_DIR && !S_ISDIR(st.st_mode))) {
12345 + xputs("mismatch in d_type");
12346 + } else if (d->d_type != DT_REG && d->d_type != DT_DIR) {
12347 + xputs("unexpected d_type");
12350 + if (telldir(D) != d->d_off) {
12351 + xputs("mismatch with telldir");
12354 + unlink(d->d_name);
12359 + xputs("did not got all expected files");
12364 diff -urN -x .git dietlibc-0.33/test/regex.c dietlibc/test/regex.c
12365 --- dietlibc-0.33/test/regex.c 2010-09-25 17:03:28.000000000 +0000
12366 +++ dietlibc/test/regex.c 2015-01-01 12:14:43.534938894 +0000
12367 @@ -117,6 +117,9 @@
12368 assert(regexec(&r,"foobarfoo",10,matches,0)==0);
12371 + assert(regcomp(&r,"^(postmaster|abuse|(felix|leitner|zoke|sanjiyan|dreesen|akuma|braun|kristine|gilda|oskar|moritz)(-[^@]*|))@qarx.de$",REG_NOSUB|REG_EXTENDED)==0);
12372 + assert(regexec(&r,"apollo.bingo-ev.de@fefe.de",10,matches,0)!=0);
12375 printf("regcomp %d\n",regcomp(&r,"\\.( ? ? ?\\.)*\\.",REG_EXTENDED|REG_NOSUB));
12376 printf("regexec %d\n",regexec(&r,buf,1,0,0));
12377 diff -urN -x .git dietlibc-0.33/test/runtests.sh dietlibc/test/runtests.sh
12378 --- dietlibc-0.33/test/runtests.sh 2012-01-24 18:24:29.000000000 +0000
12379 +++ dietlibc/test/runtests.sh 2015-01-01 12:14:43.534938894 +0000
12381 SUBDIRS="dirent inet stdio string stdlib time"
12383 -TESTPROGRAMS="adjtime alarm argv atexit bsearch byteswap calloc confstr empty fadvise flush fputc ffs fnmatch ftw fwrite getaddrinfo getenv getdelim getgrnam gethostbyaddr gethostbyname gethostbyname_r getmntent getopt getpwnam getservbyname getservbyport getusershell glob grent hasmntopt hello iconv if_nameindex ltostr malloc-debugger md5_testharness memccpy memchr memcmp memrchr memusage mktime mmap_test pipe printf printftest protoent prototypes putenv pwent rand48 readdir regex select sendfile servent siglist speed spent sprintf sscanf stdarg strcasecmp strcmp strncat strncpy strptime strrchr strstr strtol sysenter ungetc utime waitpid"
12384 +TESTPROGRAMS="adjtime alarm argv asctime atexit atfile bsearch byteswap calloc confstr empty fadvise flush fputc ffs fnmatch ftruncate ftw fwrite getaddrinfo getenv getdelim getgrnam gethostbyaddr gethostbyname gethostbyname_r getmntent getopt getpwnam getservbyname getservbyport getusershell glob grent hasmntopt hello iconv if_nameindex ltostr malloc-debugger math md5_testharness memccpy memchr memcmp memrchr memusage mktime mmap_test pipe printf printftest protoent prototypes putenv pwent rand48 readdir regex select sendfile servent setjmp siglist sigsetjmp speed spent sprintf sscanf stdarg strcasecmp strcmp strncat strncpy strptime strrchr strstr strtol sysconf sysenter ungetc utime waitpid"
12388 diff -urN -x .git dietlibc-0.33/test/runtests-X.sh dietlibc/test/runtests-X.sh
12389 --- dietlibc-0.33/test/runtests-X.sh 1970-01-01 00:00:00.000000000 +0000
12390 +++ dietlibc/test/runtests-X.sh 2015-01-01 12:14:43.534938894 +0000
12395 + ":asprintf" # requires special cmdline
12396 + ":getpass" # expects input from TTY
12397 + ":read1" # expects input
12398 + ":stdio:tst-ferror" # expects input
12399 + ":stdio:tstscanf" # expects input
12400 + ":stdlib:testdiv" # expects input
12404 + ":gethostbyname" # network test; net might not be available in test environment
12405 + ":gethostbyname_r" # network test; net might not be available in test environment
12407 + ":stdlib:tst-environ" # test uses environ function in unsupported ways (dup keys)
12408 + ":stdlib:tst-rand48" # platform dependent; does not give reliable results
12409 + ":stdlib:tst-strtod" # infinite recursion in __dtostr()
12410 + ":time:tst-mktime" # dietlibc does not support $TZ env
12411 + ":time:tst-posixtz" # dietlibc does not support $TZ env
12412 + ":time:tst-strftime" # dietlibc does not support glibc specific format specifications
12415 +FAILURES_BOGUS_emulator=(
12416 + ":adjtime" # ajdtimex() not implement in qemu
12417 + ":if_nameindex" # ioctls not implement in qemu
12418 + ":mmap_test" # qemu does not pass back mmap(2) error codes
12419 + ":fadvise" # bad translation of 64bit args in qemu
12420 + ":stdio:tst-fseek" # !! unclear; must be investigated
12421 + ":dirent:tst-seekdir" # 32/64 bit issue when calling lseek()
12425 + ":sendfile" # stdin/stdout not supported; test must be wrapped
12426 + ":sigsetjmp" # fp test fails when registers are on stack
12427 + ":stdio:tstdiomisc" # scanf(3) fails on some constructs
12428 + ":stdio:tst-fphex" # printf(3) does not support %a specifiers
12429 + ":stdio:tst-printf" # printf(3) does not support some floating point ops
12430 + ":stdio:tst-sscanf" # scanf(3) fails on double input
12431 + ":stdlib:test-canon" # realpath(3) is broken...
12434 +TESTENV=.testenv.sh
12436 +function is_in() {
12442 + test x"$i" != x"$val" || return 0
12447 +function getenv() {
12448 + local _e=testenv.sh
12450 + if ${1:-false} || \
12451 + test ! -e $TESTENV -o \
12452 + Makefile -nt $TESTENV -o \
12453 + runtests.sh -nt $TESTENV; then
12454 + eval $(grep '^\(SUBDIRS\)=' runtests.sh)
12455 + eval $(make --no-print-directory \
12456 + --eval 'print-tests:;@echo TESTPROGRAMS=\"$(sort $(TESTPROGRAMS))\"' \
12462 + printf "SUBDIRS='%s'\n" "$SUBDIRS"
12463 + printf "TESTPROGRAMS='%s'\n" "$TESTPROGRAMS"
12475 + TESTPROGRAMS= # skip tests; progress subdirs only
12479 + install -d -m 0755 $2/$TESTDIR
12480 + install -p -m 0755 $TESTPROGRAMS $TESTENV $2/$TESTDIR/
12490 +: ${ME:=${BASH_SOURCE[0]}}
12492 +: ${RUNTEST_INDENT=0}
12495 +export RUNTEST_INDENT
12501 + *) ME=`pwd`/$ME;;
12504 +test -z "$EMULATOR" || \
12505 + FAILURES_BOGUS=( "${FAILURES_BOGUS[@]}" "${FAILURES_BOGUS_emulator[@]}" )
12507 +for p in $TESTPROGRAMS; do
12508 + ! tty -s || printf '%*s%-20s' $RUNTEST_INDENT '' "$p"
12510 + is_in "$RUNTEST_NS:$p" "${FAILURES_BOGUS[@]}" && fail_bogus=true || fail_bogus=false
12511 + is_in "$RUNTEST_NS:$p" "${FAILURES_KNOWN[@]}" && fail_known=true || fail_known=false
12513 + if is_in "$RUNTEST_NS:$p" "${SKIP[@]}"; then
12516 + $EMULATOR ./$p >/dev/null && failed=false || failed=true
12518 + case $failed:$fail_known:$fail_bogus in
12519 + (false:false:*) res='OK';;
12520 + (false:true:true) res='OK (bogus)';;
12521 + (false:true:false) res="OK (unexpected)"; let ++rc;;
12522 + (true:*:true) res='FAIL (bogus)';;
12523 + (true:true:*) res="FAIL (known)";;
12524 + (true:false:*) res='FAIL'; let ++rc;;
12528 + ! tty -s || printf '\r'
12530 + printf '%*s%-20s%s\n' $RUNTEST_INDENT '' "$p" "$res"
12533 +test $rc -eq 0 || \
12534 + printf "%*s--> %u tests failed\n" $RUNTEST_INDENT '' $rc
12536 +orig_testdir=$TESTDIR
12538 +for d in $SUBDIRS; do
12539 + echo "--- entering directory $d ---"
12540 + let RUNTEST_INDENT+=2
12541 + old_ns=$RUNTEST_NS
12542 + RUNTEST_NS=$RUNTEST_NS:$d
12544 + TESTDIR=$orig_testdir/$d
12545 + cd $d && bash $ME "$@" || let ++rc
12547 + RUNTEST_NS=$old_ns
12548 + let RUNTEST_INDENT-=2
12550 + cd $OLDPWD || exit 1
12553 +test $rc -eq 0 && exit 0 || exit 1
12554 diff -urN -x .git dietlibc-0.33/test/sendfile.c dietlibc/test/sendfile.c
12555 --- dietlibc-0.33/test/sendfile.c 2003-12-15 13:07:42.000000000 +0000
12556 +++ dietlibc/test/sendfile.c 2015-01-01 12:14:43.534938894 +0000
12559 printf("sendfile returned %d\n",ret);
12562 + return ret<0 ? 1 : 0;
12564 diff -urN -x .git dietlibc-0.33/test/setjmp.c dietlibc/test/setjmp.c
12565 --- dietlibc-0.33/test/setjmp.c 1970-01-01 00:00:00.000000000 +0000
12566 +++ dietlibc/test/setjmp.c 2015-01-01 12:14:43.534938894 +0000
12568 +#include <assert.h>
12569 +#include <stdlib.h>
12570 +#include <string.h>
12571 +#include <setjmp.h>
12573 +static int Xmemcmp(void const volatile *a, void const volatile *b, size_t l)
12575 + return memcmp((void const *)a, (void const *)b, l);
12580 + char volatile a[8] = "testbufA";
12582 + char volatile b[8] = "testbufB";
12584 + assert(Xmemcmp(a, "testbufA", 8) == 0);
12585 + assert(Xmemcmp(b, "testbufB", 8) == 0);
12588 + /* Test 1: not calling longjmp */
12589 + if (setjmp(env) == 0) {
12590 + char volatile somebuf[128];
12592 + memset((void *)somebuf, 0xde, sizeof somebuf);
12594 + assert(Xmemcmp(a, "testbufA", 8) == 0);
12595 + assert(Xmemcmp(b, "testbufB", 8) == 0);
12599 + assert(Xmemcmp(a, "testbufA", 8) == 0);
12600 + assert(Xmemcmp(b, "testbufB", 8) == 0);
12603 + /* Test 2: calling longjmp */
12604 + switch (setjmp(env)) {
12606 + char volatile somebuf[128];
12608 + memset((void *)somebuf, 0xde, sizeof somebuf);
12610 + assert(Xmemcmp(a, "testbufA", 8) == 0);
12611 + assert(Xmemcmp(b, "testbufB", 8) == 0);
12613 + longjmp(env, 23);
12626 + assert(Xmemcmp(a, "testbufA", 8) == 0);
12627 + assert(Xmemcmp(b, "testbufB", 8) == 0);
12630 + /* Test 3: calling longjmp again with dirty env */
12631 + switch (setjmp(env)) {
12633 + char volatile somebuf[128];
12635 + memset((void *)somebuf, 0xde, sizeof somebuf);
12637 + assert(Xmemcmp(a, "testbufA", 8) == 0);
12638 + assert(Xmemcmp(b, "testbufB", 8) == 0);
12640 + longjmp(env, 23);
12653 + assert(Xmemcmp(a, "testbufA", 8) == 0);
12654 + assert(Xmemcmp(b, "testbufB", 8) == 0);
12657 + /* Test 4: not calling longjmp, but dirty env */
12658 + if (setjmp(env) == 0) {
12659 + char volatile somebuf[128];
12661 + memset((void *)somebuf, 0xde, sizeof somebuf);
12663 + assert(Xmemcmp(a, "testbufA", 8) == 0);
12664 + assert(Xmemcmp(b, "testbufB", 8) == 0);
12668 + assert(Xmemcmp(a, "testbufA", 8) == 0);
12669 + assert(Xmemcmp(b, "testbufB", 8) == 0);
12672 + return EXIT_SUCCESS;
12674 diff -urN -x .git dietlibc-0.33/test/sigsetjmp.c dietlibc/test/sigsetjmp.c
12675 --- dietlibc-0.33/test/sigsetjmp.c 1970-01-01 00:00:00.000000000 +0000
12676 +++ dietlibc/test/sigsetjmp.c 2015-01-01 12:14:43.534938894 +0000
12678 +#include <assert.h>
12679 +#include <stdlib.h>
12680 +#include <stddef.h>
12681 +#include <stdio.h>
12682 +#include <string.h>
12683 +#include <signal.h>
12684 +#include <setjmp.h>
12686 +#define TEST_PATTERN \
12687 + "0123456789abcdefghijklmnopqrstuv" \
12688 + "ZYXWVUTSRQPONMLKJIHGFEDCBA987654" \
12689 + "456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" \
12690 + "vutsrqponmlkjihgfedcba9876543210" \
12691 + "0123456789ABCDEFGHIJKLMNOPQRSTUV" \
12692 + "zyxwvutsrqponmlkjihgfedcba987654" \
12693 + "456789abcdefghijklmnopqrstuvwxyz" \
12694 + "VUTSRQPONMLKJIHGFEDCBA987654321" \
12697 + char volatile a[256];
12699 + char volatile b[256];
12701 + .a = TEST_PATTERN "<",
12702 + .b = TEST_PATTERN ">",
12705 +static double const volatile FP_REF[] = {
12706 + 0.4, 0.8, 1.5, 1.6, 2.3, 4.2
12709 +static int volatile sig_seen;
12711 +#define VALIDATE_BUFFERS(_sig_exp) do { \
12712 + assert(Xmemcmp(sigenv.a, TEST_PATTERN "<", sizeof sigenv.a) == 0); \
12713 + assert(Xmemcmp(sigenv.b, TEST_PATTERN ">", sizeof sigenv.b) == 0); \
12714 + assert(sig_seen == (_sig_exp)); \
12717 +static int Xmemcmp(void const volatile *a, void const volatile *b, size_t l)
12719 + return memcmp((void const *)a, (void const *)b, l);
12722 +static void do_test(int sig_num, int do_save, int block_sig)
12725 + sigset_t block_set;
12726 + sigset_t cur_set;
12728 + printf("%s(%d,%d,%d)... ", __func__, sig_num, do_save, block_sig);
12731 + VALIDATE_BUFFERS(0);
12733 + sigemptyset(&block_set);
12734 + assert(sigprocmask(SIG_SETMASK, NULL, &cur_set) == 0);
12736 + /* verify that tested signal is not blocked */
12737 + if (sig_num != 0)
12738 + assert(!sigismember(&cur_set, sig_num));
12740 + /* verify that blocked signal is not already blocked and fill signal set */
12741 + if (block_sig != 0) {
12742 + assert(!sigismember(&cur_set, block_sig));
12743 + sigaddset(&block_set, block_sig);
12747 + rc = sigsetjmp(sigenv.env, do_save);
12749 + char volatile somebuf[128];
12751 + memset((void *)somebuf, 0x42, sizeof somebuf);
12752 + VALIDATE_BUFFERS(0);
12754 + /* modify signal mask */
12755 + if (block_sig != 0)
12756 + assert(sigprocmask(SIG_BLOCK, &block_set, NULL) == 0);
12758 + /* raise a signal which triggers a siglongjmp */
12759 + if (sig_num != 0) {
12761 + sigenv.a[0] = 'X';
12762 + sigenv.b[0] = 'X';
12765 + } else if (rc != sig_num)
12766 + /* sigsetjmp() returned with an unexpected value */
12769 + VALIDATE_BUFFERS(sig_num);
12772 + /* check whether current signal mask contains the blocked signal; it should
12773 + be there iff sigsetjmp() was triggered and sigmask was saved. */
12774 + if (block_sig != 0) {
12775 + sigset_t cur_set;
12776 + assert(sigprocmask(SIG_SETMASK, NULL, &cur_set) == 0);
12778 + if (do_save && rc != 0)
12779 + assert(!sigismember(&cur_set, block_sig));
12781 + assert( sigismember(&cur_set, block_sig));
12782 + sigprocmask(SIG_UNBLOCK, &block_set, NULL);
12789 +static void do_test_fp(int sig_num, int do_save)
12791 + sigset_t cur_set;
12793 + double fp0, fp1, fp2, fp3;
12795 + printf("%s(%d,%d)... ", __func__, sig_num, do_save);
12798 + VALIDATE_BUFFERS(0);
12800 + assert(sigprocmask(SIG_SETMASK, NULL, &cur_set) == 0);
12802 + /* verify that tested signal is not blocked */
12803 + if (sig_num != 0)
12804 + assert(!sigismember(&cur_set, sig_num));
12812 + rc = sigsetjmp(sigenv.env, do_save);
12818 + if (sig_num != 0) {
12822 + } else if (rc != sig_num)
12823 + /* sigsetjmp() returned with an unexpected value */
12826 + assert(fp1 == FP_REF[1]);
12827 + assert(fp2 == FP_REF[2]);
12829 + if (sig_num == 0) {
12830 + /* "exception" was not triggered; we should see the new values */
12831 + assert(fp0 == FP_REF[4]);
12832 + assert(fp3 == FP_REF[5]);
12834 + /* "exception" was triggered; we should see the old values */
12835 + assert(fp0 == FP_REF[0]);
12836 + assert(fp3 == FP_REF[3]);
12839 + VALIDATE_BUFFERS(sig_num);
12845 +static void sig_handler(int num)
12847 + assert(sig_seen == 0);
12849 + siglongjmp(sigenv.env, num);
12854 + struct sigaction sigact = {
12855 + .sa_handler = sig_handler,
12856 + .sa_flags = SA_NODEFER, /* raised signal will be in blocked mask else */
12859 + /* verify our assumptions about the memory layout */
12860 + assert(sizeof sigenv.a == 256);
12861 + assert(sizeof sigenv.b == 256);
12862 + assert(offsetof(__typeof__(sigenv), env) == sizeof sigenv.a);
12863 + assert(offsetof(__typeof__(sigenv), b) == sizeof sigenv.a + sizeof sigenv.env);
12865 + sigaction(SIGBUS, &sigact, NULL);
12866 + sigaction(SIGUSR1, &sigact, NULL);
12868 + do_test(0, 0, 0);
12869 + do_test(0, 0, SIGUSR1);
12870 + do_test(0, 1, 0);
12871 + do_test(0, 1, SIGUSR1);
12872 + do_test(SIGBUS, 0, 0);
12873 + do_test(SIGBUS, 0, SIGUSR1);
12874 + do_test(SIGBUS, 1, 0);
12875 + do_test(SIGBUS, 1, SIGUSR1);
12877 + do_test_fp(0, 0);
12878 + do_test_fp(0, 1);
12879 + do_test_fp(SIGBUS, 0);
12880 + do_test_fp(SIGBUS, 1);
12882 + return EXIT_SUCCESS;
12884 diff -urN -x .git dietlibc-0.33/test/speed.c dietlibc/test/speed.c
12885 --- dietlibc-0.33/test/speed.c 2003-12-15 13:07:42.000000000 +0000
12886 +++ dietlibc/test/speed.c 2015-01-01 12:14:43.534938894 +0000
12891 - printf("%d\n", time(0));
12892 + printf("%ld\n", (long)time(0));
12893 for (i=0; i<10000000; ++i)
12896 - printf("%d\n", time(0));
12897 + printf("%ld\n", (long)time(0));
12900 diff -urN -x .git dietlibc-0.33/test/stat.c dietlibc/test/stat.c
12901 --- dietlibc-0.33/test/stat.c 1970-01-01 00:00:00.000000000 +0000
12902 +++ dietlibc/test/stat.c 2015-01-01 12:14:43.534938894 +0000
12904 +#define _FILE_OFFSET_BITS 64
12905 +#include <sys/types.h>
12906 +#include <sys/stat.h>
12907 +#include <sys/time.h>
12908 +#include <stdio.h>
12909 +#include <stdlib.h>
12910 +#include <fcntl.h>
12911 +#include <unistd.h>
12914 + int fd=open("/tmp/foo",O_CREAT|O_WRONLY|O_EXCL,0666);
12915 + struct timeval tv[2];
12921 + lseek(fd,0x100000000,SEEK_SET);
12924 + tv[0].tv_sec=123456789;
12926 + tv[1].tv_sec=123456789;
12928 + if (utimes("/tmp/foo",tv)) {
12929 + perror("utimes");
12930 + unlink("/tmp/foo");
12933 + if (stat("/tmp/foo",&s)) {
12935 + unlink("/tmp/foo");
12938 + printf("size %lld, atime %ld, mtime %ld, inode %ld\n",(long long)s.st_size,(long)s.st_atime,(long)s.st_mtime,(long)s.st_ino);
12939 + unlink("/tmp/foo");
12941 diff -urN -x .git dietlibc-0.33/test/stdio/.gitignore dietlibc/test/stdio/.gitignore
12942 --- dietlibc-0.33/test/stdio/.gitignore 1970-01-01 00:00:00.000000000 +0000
12943 +++ dietlibc/test/stdio/.gitignore 2015-01-01 12:14:43.534938894 +0000
12959 diff -urN -x .git dietlibc-0.33/test/stdio/tstscanf.c dietlibc/test/stdio/tstscanf.c
12960 --- dietlibc-0.33/test/stdio/tstscanf.c 2003-12-15 13:07:42.000000000 +0000
12961 +++ dietlibc/test/stdio/tstscanf.c 2015-01-01 12:14:43.534938894 +0000
12962 @@ -338,14 +338,14 @@
12965 res = sscanf ("-InF", "%f", &value);
12966 - if (res != 1 || isinf (value) != -1)
12967 + if (res != 1 || !isinf (value) || !(value<0))
12969 fputs ("test failed!\n", stdout);
12973 res = sscanf ("+InfiNiTY", "%f", &value);
12974 - if (res != 1 || isinf (value) != 1)
12975 + if (res != 1 || !isinf (value) || !(value>0))
12977 fputs ("test failed!\n", stdout);
12979 diff -urN -x .git dietlibc-0.33/test/stdlib/.gitignore dietlibc/test/stdlib/.gitignore
12980 --- dietlibc-0.33/test/stdlib/.gitignore 1970-01-01 00:00:00.000000000 +0000
12981 +++ dietlibc/test/stdlib/.gitignore 2015-01-01 12:14:43.538272226 +0000
12996 diff -urN -x .git dietlibc-0.33/test/stdlib/testsort.c dietlibc/test/stdlib/testsort.c
12997 --- dietlibc-0.33/test/stdlib/testsort.c 2003-12-15 13:07:42.000000000 +0000
12998 +++ dietlibc/test/stdlib/testsort.c 2015-01-01 12:14:43.538272226 +0000
13000 +#define _BSD_SOURCE
13002 #include <stdlib.h>
13003 #include <string.h>
13005 diff -urN -x .git dietlibc-0.33/test/stdlib/tst-calloc.c dietlibc/test/stdlib/tst-calloc.c
13006 --- dietlibc-0.33/test/stdlib/tst-calloc.c 2003-12-15 13:07:42.000000000 +0000
13007 +++ dietlibc/test/stdlib/tst-calloc.c 2015-01-01 12:14:43.538272226 +0000
13009 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
13012 +#define _BSD_SOURCE
13015 #include <limits.h>
13016 #include <malloc.h>
13017 diff -urN -x .git dietlibc-0.33/test/stdlib/tst-malloc.c dietlibc/test/stdlib/tst-malloc.c
13018 --- dietlibc-0.33/test/stdlib/tst-malloc.c 2003-12-15 13:07:42.000000000 +0000
13019 +++ dietlibc/test/stdlib/tst-malloc.c 2015-01-01 12:14:43.538272226 +0000
13020 @@ -21,13 +21,15 @@
13021 #include <stdlib.h>
13024 +#include "../../dietfeatures.h"
13026 static int errors = 0;
13029 merror (const char *msg)
13032 - printf ("Error: %s\n", msg);
13033 + fprintf (stderr, "Error: %s\n", msg);
13039 merror ("realloc (p, 0) failed.");
13041 +#ifdef WANT_MALLOC_ZERO
13044 merror ("malloc (0) failed.");
13047 p = realloc (p, 0);
13049 diff -urN -x .git dietlibc-0.33/test/stdlib/tst-strtod.c dietlibc/test/stdlib/tst-strtod.c
13050 --- dietlibc-0.33/test/stdlib/tst-strtod.c 2003-12-15 13:07:42.000000000 +0000
13051 +++ dietlibc/test/stdlib/tst-strtod.c 2015-01-01 12:14:43.538272226 +0000
13052 @@ -149,10 +149,10 @@
13055 const char input2[] = "+1.000000000116415321826934814453125";
13056 - if (strtold (input2, NULL) != +1.000000000116415321826934814453125)
13057 + if (strtold (input2, NULL) != +1.000000000116415321826934814453125L)
13059 printf ("input2: %La != %La\n", strtold (input2, NULL),
13060 - +1.000000000116415321826934814453125);
13061 + +1.000000000116415321826934814453125L);
13065 diff -urN -x .git dietlibc-0.33/test/string/.gitignore dietlibc/test/string/.gitignore
13066 --- dietlibc-0.33/test/string/.gitignore 1970-01-01 00:00:00.000000000 +0000
13067 +++ dietlibc/test/string/.gitignore 2015-01-01 12:14:43.538272226 +0000
13085 diff -urN -x .git dietlibc-0.33/test/sysconf.c dietlibc/test/sysconf.c
13086 --- dietlibc-0.33/test/sysconf.c 1970-01-01 00:00:00.000000000 +0000
13087 +++ dietlibc/test/sysconf.c 2015-01-01 12:14:43.538272226 +0000
13089 +#include <unistd.h>
13090 +#include <stdio.h>
13091 +#include <stdlib.h>
13092 +#include <assert.h>
13093 +#include <sys/wait.h>
13095 +#include "../dietpagesize.h"
13097 +static long exec_getconf(char const *var)
13105 + if (pipe(fd)<0 || (pid = fork())<0)
13116 + execlp("getconf", "getconf", var, NULL);
13121 + l = read(fd[0], buf, sizeof(buf)-1);
13123 + perror("read()");
13125 + } else if (l==sizeof(buf)-1)
13131 + if (waitpid(pid, &status, 0)<0)
13134 + if (!WIFEXITED(status) || WEXITSTATUS(status)!=0)
13137 + return strtol(buf, NULL, 10);
13140 + kill(pid, SIGKILL);
13144 +static unsigned int do_check(char const *var, long exp)
13146 + long cur = exec_getconf(var);
13149 + fprintf(stderr, "%s mismatch: got %ld, expected %ld\n",
13157 +int main(int argc, char *argv[])
13159 + unsigned int err = 0;
13161 + assert(sysconf(_SC_PAGESIZE) == __DIET_PAGE_SIZE);
13162 + assert(__DIET_PAGE_SIZE == (1<<__DIET_PAGE_SHIFT));
13164 + err += do_check("PAGE_SIZE", sysconf(_SC_PAGESIZE));
13165 + err += do_check("CLK_TCK", sysconf(_SC_CLK_TCK));
13169 diff -urN -x .git dietlibc-0.33/test/sysenter.c dietlibc/test/sysenter.c
13170 --- dietlibc-0.33/test/sysenter.c 2003-12-15 13:07:42.000000000 +0000
13171 +++ dietlibc/test/sysenter.c 2015-01-01 12:14:43.538272226 +0000
13172 @@ -11,11 +11,11 @@
13174 for (i=0; environ[i]; ++i) ;
13175 for (x=(struct elf_aux*)(environ+i+1); x->type; ++x) {
13176 - printf("%d %x\n",x->type,x->value);
13177 + printf("%ld %lx\n",x->type,x->value);
13178 if (x->type==AT_PAGESZ)
13179 - printf("pagesize %d\n",x->value);
13180 + printf("pagesize %ld\n",x->value);
13181 else if (x->type==AT_SYSINFO)
13182 - printf("vsyscall %p\n",x->value);
13183 + printf("vsyscall %p\n",(void *)x->value);
13187 diff -urN -x .git dietlibc-0.33/test/thread.c dietlibc/test/thread.c
13188 --- dietlibc-0.33/test/thread.c 1970-01-01 00:00:00.000000000 +0000
13189 +++ dietlibc/test/thread.c 2015-01-01 12:14:43.538272226 +0000
13191 +#define _REENTRANT
13192 +#include <threads.h>
13193 +#include <stdio.h>
13194 +#include <unistd.h>
13195 +#include <assert.h>
13196 +#include <write12.h>
13198 +#include <errno.h>
13204 +int thread(void* arg) {
13208 + for (i=0; i<100; ++i) {
13216 +int thread2(void* arg) {
13223 +int recursive_lock(int a) {
13226 + return recursive_lock(a-1);
13232 +int thread3(void* arg) {
13233 + recursive_lock(5);
13236 +once_flag f=ONCE_FLAG_INIT;
13238 +void callme(void) {
13239 + __write1("callme got called\n");
13242 +int thread4(void* arg) {
13243 + call_once(&f,callme);
13250 +int thread5(void* arg) {
13251 + cnd_wait(&cond,&m);
13252 +// __write1("thread5\n");
13257 +int thread6(void* arg) {
13259 + assert(write(-1,"foo",3)==-1);
13260 + assert(errno==EBADF);
13265 + thrd_t threads[16];
13267 + mtx_init(&m,mtx_plain);
13269 + __write1("plain mutex test\n");
13270 + for (i=0; i<sizeof(threads)/sizeof(threads[0]); ++i) {
13271 + assert(thrd_create(threads+i,thread,NULL)==thrd_success);
13273 + for (i=0; i<sizeof(threads)/sizeof(threads[0]); ++i) {
13275 + assert(thrd_join(threads[i],&r)==thrd_success && r==23);
13277 + assert(l==100*sizeof(threads)/sizeof(threads[0]));
13279 + __write1("mtx_timedlock test\n");
13280 + assert(thrd_create(threads,thread2,NULL)==thrd_success);
13282 + struct timespec ts;
13284 + ts.tv_nsec=10000;
13285 + nanosleep(&ts,0);
13286 + assert(mtx_timedlock(&m,&ts)==thrd_timedout);
13290 + assert(thrd_join(threads[0],&r)==thrd_success);
13294 + __write1("mtx_recursive test\n");
13295 + mtx_init(&m,mtx_recursive);
13296 + assert(thrd_create(threads,thread3,NULL)==thrd_success);
13298 + struct timespec ts;
13300 + ts.tv_nsec=10000;
13301 + nanosleep(&ts,0);
13302 + // at this point thread3 should be running, and it should have
13303 + // locked the recursive lock, and be inside the sleep(1);
13304 + assert(mtx_trylock(&m)==thrd_busy);
13308 + assert(thrd_join(threads[0],&r)==thrd_success);
13311 + __write1("call_once test\n");
13312 + for (i=0; i<sizeof(threads)/sizeof(threads[0]); ++i) {
13313 + assert(thrd_create(threads+i,thread4,NULL)==thrd_success);
13315 + for (i=0; i<sizeof(threads)/sizeof(threads[0]); ++i) {
13317 + assert(thrd_join(threads[i],&r)==thrd_success && r==0);
13320 + __write1("cnd_t test\n");
13322 + mtx_init(&m,mtx_plain);
13323 + for (i=0; i<sizeof(threads)/sizeof(threads[0]); ++i) {
13324 + assert(thrd_create(threads+i,thread5,NULL)==thrd_success);
13325 + assert(thrd_detach(threads[i])==thrd_success);
13328 + struct timespec ts;
13330 + ts.tv_nsec=100000000;
13331 + nanosleep(&ts,0);
13332 + cnd_signal(&cond);
13333 + nanosleep(&ts,0);
13337 + cnd_broadcast(&cond);
13338 + nanosleep(&ts,0);
13340 + assert(done==sizeof(threads)/sizeof(threads[0]));
13345 + assert(write(-1,"foo",3)==-1);
13346 + assert(errno==EBADF);
13348 + assert(thrd_create(threads,thread6,NULL)==thrd_success);
13349 + assert(thrd_join(threads[0],NULL)==thrd_success);
13353 diff -urN -x .git dietlibc-0.33/test/time/.gitignore dietlibc/test/time/.gitignore
13354 --- dietlibc-0.33/test/time/.gitignore 1970-01-01 00:00:00.000000000 +0000
13355 +++ dietlibc/test/time/.gitignore 2015-01-01 12:14:43.538272226 +0000
13361 diff -urN -x .git dietlibc-0.33/test/time/tst-strftime.c dietlibc/test/time/tst-strftime.c
13362 --- dietlibc-0.33/test/time/tst-strftime.c 2003-12-15 13:07:42.000000000 +0000
13363 +++ dietlibc/test/time/tst-strftime.c 2015-01-01 12:14:43.538272226 +0000
13364 @@ -49,18 +49,18 @@
13368 - printf ("%Zu: %s: res == 0 despite size == %Zu\n",
13369 + printf ("%zu: %s: res == 0 despite size == %zu\n",
13370 cnt, tests[cnt].fmt, size);
13373 else if (size < tests[cnt].min)
13375 - printf ("%Zu: %s: size == %Zu was enough\n",
13376 + printf ("%zu: %s: size == %zu was enough\n",
13377 cnt, tests[cnt].fmt, size);
13381 - printf ("%Zu: %s: size == %Zu: OK\n", cnt, tests[cnt].fmt, size);
13382 + printf ("%zu: %s: size == %zu: OK\n", cnt, tests[cnt].fmt, size);
13386 diff -urN -x .git dietlibc-0.33/test/time/tst-strptime.c dietlibc/test/time/tst-strptime.c
13387 --- dietlibc-0.33/test/time/tst-strptime.c 2003-12-15 13:07:42.000000000 +0000
13388 +++ dietlibc/test/time/tst-strptime.c 2015-01-01 12:14:43.538272226 +0000
13389 @@ -41,10 +41,12 @@
13390 { "C", "03/03/00", "%D", 5, 62, 2, 3 },
13391 { "C", "9/9/99", "%x", 4, 251, 8, 9 },
13392 { "C", "19990502123412", "%Y%m%d%H%M%S", 0, 121, 4, 2 },
13393 +#if 0 /* dietlibc does not support %U/%W/%j and non-POSIX locales */
13394 { "C", "2001 20 Mon", "%Y %U %a", 1, 140, 4, 21 },
13395 { "C", "2001 21 Mon", "%Y %W %a", 1, 140, 4, 21 },
13396 { "ja_JP.EUC-JP", "2001 20 \xb7\xee", "%Y %U %a", 1, 140, 4, 21 },
13397 { "ja_JP.EUC-JP", "2001 21 \xb7\xee", "%Y %W %a", 1, 140, 4, 21 },
13404 for (i = 0; i < sizeof (tm_tests) / sizeof (tm_tests[0]); ++i)
13407 memset (&tm, '\0', sizeof (tm));
13409 - if (strptime (tm_tests[i].input, tm_tests[i].format, &tm) != '\0')
13411 + pres = strptime (tm_tests[i].input, tm_tests[i].format, &tm);
13414 + fprintf(stderr, "failed to parse '%s'\n", day_tests[i].input);
13417 + else if (*pres != '\0')
13419 printf ("not all of `%s' read\n", tm_tests[i].input);
13421 @@ -118,6 +127,7 @@
13423 for (i = 0; i < sizeof (day_tests) / sizeof (day_tests[0]); ++i)
13426 memset (&tm, '\0', sizeof (tm));
13428 if (setlocale (LC_ALL, day_tests[i].locale) == NULL)
13429 @@ -125,7 +135,14 @@
13430 printf ("cannot set locale %s: %m\n", day_tests[i].locale);
13433 - if (*strptime (day_tests[i].input, day_tests[i].format, &tm) != '\0')
13434 + pres = strptime (day_tests[i].input, day_tests[i].format, &tm);
13437 + fprintf(stderr, "failed to parse '%s' for locale '%s'\n",
13438 + day_tests[i].input, day_tests[i].locale);
13441 + else if (*pres != '\0')
13443 printf ("not all of `%s' read\n", day_tests[i].input);
13445 diff -urN -x .git dietlibc-0.33/test/unaligned.c dietlibc/test/unaligned.c
13446 --- dietlibc-0.33/test/unaligned.c 1970-01-01 00:00:00.000000000 +0000
13447 +++ dietlibc/test/unaligned.c 2015-01-01 12:14:43.538272226 +0000
13449 +#include "../dietunaligned.h"
13450 +#include <assert.h>
13451 +#include <string.h>
13452 +#include <stdlib.h>
13454 +struct unaligned0 {
13463 + struct unaligned0 data0 = {
13469 + struct unaligned0 data1;
13471 + unsigned char *buf0 = malloc(sizeof data0 + 1);
13472 + unsigned char *buf1 = malloc(sizeof data0 + 1);
13474 + assert(buf0 != NULL);
13475 + assert(buf1 != NULL);
13477 + memcpy(buf0+1, &data0, sizeof data0);
13479 + assert(read_unaligned_s(buf0+1, struct unaligned0, u8) == data0.u8);
13480 + assert(read_unaligned_s(buf0+1, struct unaligned0, u16) == data0.u16);
13481 + assert(read_unaligned_s(buf0+1, struct unaligned0, u32) == data0.u32);
13482 + assert(read_unaligned_s(buf0+1, struct unaligned0, u64) == data0.u64);
13485 + memset(buf1, 0, sizeof data0 + 1);
13486 + write_unaligned_s(data0.u8, buf1+1, struct unaligned0, u8);
13487 + write_unaligned_s(data0.u16, buf1+1, struct unaligned0, u16);
13488 + write_unaligned_s(data0.u32, buf1+1, struct unaligned0, u32);
13489 + write_unaligned_s(data0.u64, buf1+1, struct unaligned0, u64);
13491 + memcpy(&data1, buf1+1, sizeof data1);
13492 + assert(data0.u8 == data1.u8);
13493 + assert(data0.u16 == data1.u16);
13494 + assert(data0.u32 == data1.u32);
13495 + assert(data0.u64 == data1.u64);
13502 diff -urN -x .git dietlibc-0.33/test/waitpid.c dietlibc/test/waitpid.c
13503 --- dietlibc-0.33/test/waitpid.c 2003-12-15 13:07:42.000000000 +0000
13504 +++ dietlibc/test/waitpid.c 2015-01-01 12:14:43.538272226 +0000
13509 - fprintf(stderr,"child, my pid is %u\n",getpid());
13510 + fprintf(stdout,"child, my pid is %u\n",getpid());
13514 diff -urN -x .git dietlibc-0.33/x32/Makefile.add dietlibc/x32/Makefile.add
13515 --- dietlibc-0.33/x32/Makefile.add 1970-01-01 00:00:00.000000000 +0000
13516 +++ dietlibc/x32/Makefile.add 2015-01-01 12:14:43.538272226 +0000
13518 +CFLAGS := -Os -fstrict-aliasing -momit-leaf-frame-pointer -mfancy-math-387
13519 +VPATH := x32:x86_64:syscalls.s:$(VPATH)
13520 +LIBOBJ += $(OBJDIR)/arch_prctl.o $(OBJDIR)/__CAS.o
13521 diff -urN -x .git dietlibc-0.33/x32/start.S dietlibc/x32/start.S
13522 --- dietlibc-0.33/x32/start.S 1970-01-01 00:00:00.000000000 +0000
13523 +++ dietlibc/x32/start.S 2015-01-01 12:14:43.538272226 +0000
13525 +#include "dietfeatures.h"
13530 +#ifdef WANT_DYNAMIC
13531 + movq %rdx, %rcx /* %rcx = dynamic fini */
13533 + movl (%esp), %edi /* %edi = argc */
13534 + lea 4(%esp), %esi /* %esi = argv */
13536 + leaq 4(%rsi,%rdi,4),%rdx /* %edx = envp = (4*edi)+%esi+4 */
13538 +#ifdef WANT_ELFINFO
13539 + /* untested !! */
13542 + movl environ@GOTPCREL(%rip), %eax
13544 + leal environ(%rip), %eax
13546 + movl %edx, (%eax) /* environ */
13548 +1: add $4, %edx /* incorment envp */
13549 + cmpl $0, -4(%edx) /* load envp[-1] */
13550 + jne 1b /* ... until envp[-1]==NULL */
13552 + movl %edx, 4(%eax) /* __elfinfo */
13553 +#else /* WANT_ELFINFO */
13555 + movl environ@GOTPCREL(%rip), %eax
13556 + movl %edx, (%eax)
13558 + movl %edx, environ(%rip)
13560 +#endif /* WANT_ELFINFO */
13563 + pushl %edi /* save reg args */
13568 + leal _etext(%eip), %esi /* highpc */
13569 + leal .text(%eip), %edi /* lowpc */
13572 + popl %ecx /* restore reg args */
13578 +#ifdef WANT_DYNAMIC
13581 + call CALL_IN_STARTCODE
13586 + call _stop_monitor
13589 + movl %eax, %edi /* return value */
13594 + .size _start,.Lstart-_start
13596 diff -urN -x .git dietlibc-0.33/x32/syscalls.h dietlibc/x32/syscalls.h
13597 --- dietlibc-0.33/x32/syscalls.h 1970-01-01 00:00:00.000000000 +0000
13598 +++ dietlibc/x32/syscalls.h 2015-01-01 12:14:43.538272226 +0000
13600 +/* the x32 syscall bit is 0x40000000 but we handle that inside our
13601 + * unified syscall, not here, so we can have a tiny optimization for
13602 + * small syscall numbers. We still leave the #define in so we can cut
13604 + * /usr/src/linux/arch/x86/include/generated/uapi/asm/unistd_x32.h */
13605 +#define __X32_SYSCALL_BIT 0
13607 +#define __NR_read (__X32_SYSCALL_BIT + 0)
13608 +#define __NR_write (__X32_SYSCALL_BIT + 1)
13609 +#define __NR_open (__X32_SYSCALL_BIT + 2)
13610 +#define __NR_close (__X32_SYSCALL_BIT + 3)
13611 +#define __NR_stat (__X32_SYSCALL_BIT + 4)
13612 +#define __NR_fstat (__X32_SYSCALL_BIT + 5)
13613 +#define __NR_lstat (__X32_SYSCALL_BIT + 6)
13614 +#define __NR_poll (__X32_SYSCALL_BIT + 7)
13615 +#define __NR_lseek (__X32_SYSCALL_BIT + 8)
13616 +#define __NR_mmap (__X32_SYSCALL_BIT + 9)
13617 +#define __NR_mprotect (__X32_SYSCALL_BIT + 10)
13618 +#define __NR_munmap (__X32_SYSCALL_BIT + 11)
13619 +#define __NR_brk (__X32_SYSCALL_BIT + 12)
13620 +#define __NR_rt_sigprocmask (__X32_SYSCALL_BIT + 14)
13621 +#define __NR_pread64 (__X32_SYSCALL_BIT + 17)
13622 +#define __NR_pwrite64 (__X32_SYSCALL_BIT + 18)
13623 +#define __NR_access (__X32_SYSCALL_BIT + 21)
13624 +#define __NR_pipe (__X32_SYSCALL_BIT + 22)
13625 +#define __NR_select (__X32_SYSCALL_BIT + 23)
13626 +#define __NR_sched_yield (__X32_SYSCALL_BIT + 24)
13627 +#define __NR_mremap (__X32_SYSCALL_BIT + 25)
13628 +#define __NR_msync (__X32_SYSCALL_BIT + 26)
13629 +#define __NR_mincore (__X32_SYSCALL_BIT + 27)
13630 +#define __NR_madvise (__X32_SYSCALL_BIT + 28)
13631 +#define __NR_shmget (__X32_SYSCALL_BIT + 29)
13632 +#define __NR_shmat (__X32_SYSCALL_BIT + 30)
13633 +#define __NR_shmctl (__X32_SYSCALL_BIT + 31)
13634 +#define __NR_dup (__X32_SYSCALL_BIT + 32)
13635 +#define __NR_dup2 (__X32_SYSCALL_BIT + 33)
13636 +#define __NR_pause (__X32_SYSCALL_BIT + 34)
13637 +#define __NR_nanosleep (__X32_SYSCALL_BIT + 35)
13638 +#define __NR_getitimer (__X32_SYSCALL_BIT + 36)
13639 +#define __NR_alarm (__X32_SYSCALL_BIT + 37)
13640 +#define __NR_setitimer (__X32_SYSCALL_BIT + 38)
13641 +#define __NR_getpid (__X32_SYSCALL_BIT + 39)
13642 +#define __NR_sendfile (__X32_SYSCALL_BIT + 40)
13643 +#define __NR_socket (__X32_SYSCALL_BIT + 41)
13644 +#define __NR_connect (__X32_SYSCALL_BIT + 42)
13645 +#define __NR_accept (__X32_SYSCALL_BIT + 43)
13646 +#define __NR_sendto (__X32_SYSCALL_BIT + 44)
13647 +#define __NR_shutdown (__X32_SYSCALL_BIT + 48)
13648 +#define __NR_bind (__X32_SYSCALL_BIT + 49)
13649 +#define __NR_listen (__X32_SYSCALL_BIT + 50)
13650 +#define __NR_getsockname (__X32_SYSCALL_BIT + 51)
13651 +#define __NR_getpeername (__X32_SYSCALL_BIT + 52)
13652 +#define __NR_socketpair (__X32_SYSCALL_BIT + 53)
13653 +#define __NR_clone (__X32_SYSCALL_BIT + 56)
13654 +#define __NR_fork (__X32_SYSCALL_BIT + 57)
13655 +#define __NR_vfork (__X32_SYSCALL_BIT + 58)
13656 +#define __NR_exit (__X32_SYSCALL_BIT + 60)
13657 +#define __NR_wait4 (__X32_SYSCALL_BIT + 61)
13658 +#define __NR_kill (__X32_SYSCALL_BIT + 62)
13659 +#define __NR_uname (__X32_SYSCALL_BIT + 63)
13660 +#define __NR_semget (__X32_SYSCALL_BIT + 64)
13661 +#define __NR_semop (__X32_SYSCALL_BIT + 65)
13662 +#define __NR_semctl (__X32_SYSCALL_BIT + 66)
13663 +#define __NR_shmdt (__X32_SYSCALL_BIT + 67)
13664 +#define __NR_msgget (__X32_SYSCALL_BIT + 68)
13665 +#define __NR_msgsnd (__X32_SYSCALL_BIT + 69)
13666 +#define __NR_msgrcv (__X32_SYSCALL_BIT + 70)
13667 +#define __NR_msgctl (__X32_SYSCALL_BIT + 71)
13668 +#define __NR_fcntl (__X32_SYSCALL_BIT + 72)
13669 +#define __NR_flock (__X32_SYSCALL_BIT + 73)
13670 +#define __NR_fsync (__X32_SYSCALL_BIT + 74)
13671 +#define __NR_fdatasync (__X32_SYSCALL_BIT + 75)
13672 +#define __NR_truncate (__X32_SYSCALL_BIT + 76)
13673 +#define __NR_ftruncate (__X32_SYSCALL_BIT + 77)
13674 +#define __NR_getdents (__X32_SYSCALL_BIT + 78)
13675 +#define __NR_getcwd (__X32_SYSCALL_BIT + 79)
13676 +#define __NR_chdir (__X32_SYSCALL_BIT + 80)
13677 +#define __NR_fchdir (__X32_SYSCALL_BIT + 81)
13678 +#define __NR_rename (__X32_SYSCALL_BIT + 82)
13679 +#define __NR_mkdir (__X32_SYSCALL_BIT + 83)
13680 +#define __NR_rmdir (__X32_SYSCALL_BIT + 84)
13681 +#define __NR_creat (__X32_SYSCALL_BIT + 85)
13682 +#define __NR_link (__X32_SYSCALL_BIT + 86)
13683 +#define __NR_unlink (__X32_SYSCALL_BIT + 87)
13684 +#define __NR_symlink (__X32_SYSCALL_BIT + 88)
13685 +#define __NR_readlink (__X32_SYSCALL_BIT + 89)
13686 +#define __NR_chmod (__X32_SYSCALL_BIT + 90)
13687 +#define __NR_fchmod (__X32_SYSCALL_BIT + 91)
13688 +#define __NR_chown (__X32_SYSCALL_BIT + 92)
13689 +#define __NR_fchown (__X32_SYSCALL_BIT + 93)
13690 +#define __NR_lchown (__X32_SYSCALL_BIT + 94)
13691 +#define __NR_umask (__X32_SYSCALL_BIT + 95)
13692 +#define __NR_gettimeofday (__X32_SYSCALL_BIT + 96)
13693 +#define __NR_getrlimit (__X32_SYSCALL_BIT + 97)
13694 +#define __NR_getrusage (__X32_SYSCALL_BIT + 98)
13695 +#define __NR_sysinfo (__X32_SYSCALL_BIT + 99)
13696 +#define __NR_times (__X32_SYSCALL_BIT + 100)
13697 +#define __NR_getuid (__X32_SYSCALL_BIT + 102)
13698 +#define __NR_syslog (__X32_SYSCALL_BIT + 103)
13699 +#define __NR_getgid (__X32_SYSCALL_BIT + 104)
13700 +#define __NR_setuid (__X32_SYSCALL_BIT + 105)
13701 +#define __NR_setgid (__X32_SYSCALL_BIT + 106)
13702 +#define __NR_geteuid (__X32_SYSCALL_BIT + 107)
13703 +#define __NR_getegid (__X32_SYSCALL_BIT + 108)
13704 +#define __NR_setpgid (__X32_SYSCALL_BIT + 109)
13705 +#define __NR_getppid (__X32_SYSCALL_BIT + 110)
13706 +#define __NR_getpgrp (__X32_SYSCALL_BIT + 111)
13707 +#define __NR_setsid (__X32_SYSCALL_BIT + 112)
13708 +#define __NR_setreuid (__X32_SYSCALL_BIT + 113)
13709 +#define __NR_setregid (__X32_SYSCALL_BIT + 114)
13710 +#define __NR_getgroups (__X32_SYSCALL_BIT + 115)
13711 +#define __NR_setgroups (__X32_SYSCALL_BIT + 116)
13712 +#define __NR_setresuid (__X32_SYSCALL_BIT + 117)
13713 +#define __NR_getresuid (__X32_SYSCALL_BIT + 118)
13714 +#define __NR_setresgid (__X32_SYSCALL_BIT + 119)
13715 +#define __NR_getresgid (__X32_SYSCALL_BIT + 120)
13716 +#define __NR_getpgid (__X32_SYSCALL_BIT + 121)
13717 +#define __NR_setfsuid (__X32_SYSCALL_BIT + 122)
13718 +#define __NR_setfsgid (__X32_SYSCALL_BIT + 123)
13719 +#define __NR_getsid (__X32_SYSCALL_BIT + 124)
13720 +#define __NR_capget (__X32_SYSCALL_BIT + 125)
13721 +#define __NR_capset (__X32_SYSCALL_BIT + 126)
13722 +#define __NR_rt_sigsuspend (__X32_SYSCALL_BIT + 130)
13723 +#define __NR_utime (__X32_SYSCALL_BIT + 132)
13724 +#define __NR_mknod (__X32_SYSCALL_BIT + 133)
13725 +#define __NR_personality (__X32_SYSCALL_BIT + 135)
13726 +#define __NR_ustat (__X32_SYSCALL_BIT + 136)
13727 +#define __NR_statfs (__X32_SYSCALL_BIT + 137)
13728 +#define __NR_fstatfs (__X32_SYSCALL_BIT + 138)
13729 +#define __NR_sysfs (__X32_SYSCALL_BIT + 139)
13730 +#define __NR_getpriority (__X32_SYSCALL_BIT + 140)
13731 +#define __NR_setpriority (__X32_SYSCALL_BIT + 141)
13732 +#define __NR_sched_setparam (__X32_SYSCALL_BIT + 142)
13733 +#define __NR_sched_getparam (__X32_SYSCALL_BIT + 143)
13734 +#define __NR_sched_setscheduler (__X32_SYSCALL_BIT + 144)
13735 +#define __NR_sched_getscheduler (__X32_SYSCALL_BIT + 145)
13736 +#define __NR_sched_get_priority_max (__X32_SYSCALL_BIT + 146)
13737 +#define __NR_sched_get_priority_min (__X32_SYSCALL_BIT + 147)
13738 +#define __NR_sched_rr_get_interval (__X32_SYSCALL_BIT + 148)
13739 +#define __NR_mlock (__X32_SYSCALL_BIT + 149)
13740 +#define __NR_munlock (__X32_SYSCALL_BIT + 150)
13741 +#define __NR_mlockall (__X32_SYSCALL_BIT + 151)
13742 +#define __NR_munlockall (__X32_SYSCALL_BIT + 152)
13743 +#define __NR_vhangup (__X32_SYSCALL_BIT + 153)
13744 +#define __NR_modify_ldt (__X32_SYSCALL_BIT + 154)
13745 +#define __NR_pivot_root (__X32_SYSCALL_BIT + 155)
13746 +#define __NR_prctl (__X32_SYSCALL_BIT + 157)
13747 +#define __NR_arch_prctl (__X32_SYSCALL_BIT + 158)
13748 +#define __NR_adjtimex (__X32_SYSCALL_BIT + 159)
13749 +#define __NR_setrlimit (__X32_SYSCALL_BIT + 160)
13750 +#define __NR_chroot (__X32_SYSCALL_BIT + 161)
13751 +#define __NR_sync (__X32_SYSCALL_BIT + 162)
13752 +#define __NR_acct (__X32_SYSCALL_BIT + 163)
13753 +#define __NR_settimeofday (__X32_SYSCALL_BIT + 164)
13754 +#define __NR_mount (__X32_SYSCALL_BIT + 165)
13755 +#define __NR_umount2 (__X32_SYSCALL_BIT + 166)
13756 +#define __NR_swapon (__X32_SYSCALL_BIT + 167)
13757 +#define __NR_swapoff (__X32_SYSCALL_BIT + 168)
13758 +#define __NR_reboot (__X32_SYSCALL_BIT + 169)
13759 +#define __NR_sethostname (__X32_SYSCALL_BIT + 170)
13760 +#define __NR_setdomainname (__X32_SYSCALL_BIT + 171)
13761 +#define __NR_iopl (__X32_SYSCALL_BIT + 172)
13762 +#define __NR_ioperm (__X32_SYSCALL_BIT + 173)
13763 +#define __NR_init_module (__X32_SYSCALL_BIT + 175)
13764 +#define __NR_delete_module (__X32_SYSCALL_BIT + 176)
13765 +#define __NR_quotactl (__X32_SYSCALL_BIT + 179)
13766 +#define __NR_getpmsg (__X32_SYSCALL_BIT + 181)
13767 +#define __NR_putpmsg (__X32_SYSCALL_BIT + 182)
13768 +#define __NR_afs_syscall (__X32_SYSCALL_BIT + 183)
13769 +#define __NR_tuxcall (__X32_SYSCALL_BIT + 184)
13770 +#define __NR_security (__X32_SYSCALL_BIT + 185)
13771 +#define __NR_gettid (__X32_SYSCALL_BIT + 186)
13772 +#define __NR_readahead (__X32_SYSCALL_BIT + 187)
13773 +#define __NR_setxattr (__X32_SYSCALL_BIT + 188)
13774 +#define __NR_lsetxattr (__X32_SYSCALL_BIT + 189)
13775 +#define __NR_fsetxattr (__X32_SYSCALL_BIT + 190)
13776 +#define __NR_getxattr (__X32_SYSCALL_BIT + 191)
13777 +#define __NR_lgetxattr (__X32_SYSCALL_BIT + 192)
13778 +#define __NR_fgetxattr (__X32_SYSCALL_BIT + 193)
13779 +#define __NR_listxattr (__X32_SYSCALL_BIT + 194)
13780 +#define __NR_llistxattr (__X32_SYSCALL_BIT + 195)
13781 +#define __NR_flistxattr (__X32_SYSCALL_BIT + 196)
13782 +#define __NR_removexattr (__X32_SYSCALL_BIT + 197)
13783 +#define __NR_lremovexattr (__X32_SYSCALL_BIT + 198)
13784 +#define __NR_fremovexattr (__X32_SYSCALL_BIT + 199)
13785 +#define __NR_tkill (__X32_SYSCALL_BIT + 200)
13786 +#define __NR_time (__X32_SYSCALL_BIT + 201)
13787 +#define __NR_futex (__X32_SYSCALL_BIT + 202)
13788 +#define __NR_sched_setaffinity (__X32_SYSCALL_BIT + 203)
13789 +#define __NR_sched_getaffinity (__X32_SYSCALL_BIT + 204)
13790 +#define __NR_io_destroy (__X32_SYSCALL_BIT + 207)
13791 +#define __NR_io_getevents (__X32_SYSCALL_BIT + 208)
13792 +#define __NR_io_cancel (__X32_SYSCALL_BIT + 210)
13793 +#define __NR_lookup_dcookie (__X32_SYSCALL_BIT + 212)
13794 +#define __NR_epoll_create (__X32_SYSCALL_BIT + 213)
13795 +#define __NR_remap_file_pages (__X32_SYSCALL_BIT + 216)
13796 +#define __NR_getdents64 (__X32_SYSCALL_BIT + 217)
13797 +#define __NR_set_tid_address (__X32_SYSCALL_BIT + 218)
13798 +#define __NR_restart_syscall (__X32_SYSCALL_BIT + 219)
13799 +#define __NR_semtimedop (__X32_SYSCALL_BIT + 220)
13800 +#define __NR_fadvise64 (__X32_SYSCALL_BIT + 221)
13801 +#define __NR_timer_settime (__X32_SYSCALL_BIT + 223)
13802 +#define __NR_timer_gettime (__X32_SYSCALL_BIT + 224)
13803 +#define __NR_timer_getoverrun (__X32_SYSCALL_BIT + 225)
13804 +#define __NR_timer_delete (__X32_SYSCALL_BIT + 226)
13805 +#define __NR_clock_settime (__X32_SYSCALL_BIT + 227)
13806 +#define __NR_clock_gettime (__X32_SYSCALL_BIT + 228)
13807 +#define __NR_clock_getres (__X32_SYSCALL_BIT + 229)
13808 +#define __NR_clock_nanosleep (__X32_SYSCALL_BIT + 230)
13809 +#define __NR_exit_group (__X32_SYSCALL_BIT + 231)
13810 +#define __NR_epoll_wait (__X32_SYSCALL_BIT + 232)
13811 +#define __NR_epoll_ctl (__X32_SYSCALL_BIT + 233)
13812 +#define __NR_tgkill (__X32_SYSCALL_BIT + 234)
13813 +#define __NR_utimes (__X32_SYSCALL_BIT + 235)
13814 +#define __NR_mbind (__X32_SYSCALL_BIT + 237)
13815 +#define __NR_set_mempolicy (__X32_SYSCALL_BIT + 238)
13816 +#define __NR_get_mempolicy (__X32_SYSCALL_BIT + 239)
13817 +#define __NR_mq_open (__X32_SYSCALL_BIT + 240)
13818 +#define __NR_mq_unlink (__X32_SYSCALL_BIT + 241)
13819 +#define __NR_mq_timedsend (__X32_SYSCALL_BIT + 242)
13820 +#define __NR_mq_timedreceive (__X32_SYSCALL_BIT + 243)
13821 +#define __NR_mq_getsetattr (__X32_SYSCALL_BIT + 245)
13822 +#define __NR_add_key (__X32_SYSCALL_BIT + 248)
13823 +#define __NR_request_key (__X32_SYSCALL_BIT + 249)
13824 +#define __NR_keyctl (__X32_SYSCALL_BIT + 250)
13825 +#define __NR_ioprio_set (__X32_SYSCALL_BIT + 251)
13826 +#define __NR_ioprio_get (__X32_SYSCALL_BIT + 252)
13827 +#define __NR_inotify_init (__X32_SYSCALL_BIT + 253)
13828 +#define __NR_inotify_add_watch (__X32_SYSCALL_BIT + 254)
13829 +#define __NR_inotify_rm_watch (__X32_SYSCALL_BIT + 255)
13830 +#define __NR_migrate_pages (__X32_SYSCALL_BIT + 256)
13831 +#define __NR_openat (__X32_SYSCALL_BIT + 257)
13832 +#define __NR_mkdirat (__X32_SYSCALL_BIT + 258)
13833 +#define __NR_mknodat (__X32_SYSCALL_BIT + 259)
13834 +#define __NR_fchownat (__X32_SYSCALL_BIT + 260)
13835 +#define __NR_futimesat (__X32_SYSCALL_BIT + 261)
13836 +#define __NR_newfstatat (__X32_SYSCALL_BIT + 262)
13837 +#define __NR_unlinkat (__X32_SYSCALL_BIT + 263)
13838 +#define __NR_renameat (__X32_SYSCALL_BIT + 264)
13839 +#define __NR_linkat (__X32_SYSCALL_BIT + 265)
13840 +#define __NR_symlinkat (__X32_SYSCALL_BIT + 266)
13841 +#define __NR_readlinkat (__X32_SYSCALL_BIT + 267)
13842 +#define __NR_fchmodat (__X32_SYSCALL_BIT + 268)
13843 +#define __NR_faccessat (__X32_SYSCALL_BIT + 269)
13844 +#define __NR_pselect6 (__X32_SYSCALL_BIT + 270)
13845 +#define __NR_ppoll (__X32_SYSCALL_BIT + 271)
13846 +#define __NR_unshare (__X32_SYSCALL_BIT + 272)
13847 +#define __NR_splice (__X32_SYSCALL_BIT + 275)
13848 +#define __NR_tee (__X32_SYSCALL_BIT + 276)
13849 +#define __NR_sync_file_range (__X32_SYSCALL_BIT + 277)
13850 +#define __NR_utimensat (__X32_SYSCALL_BIT + 280)
13851 +#define __NR_epoll_pwait (__X32_SYSCALL_BIT + 281)
13852 +#define __NR_signalfd (__X32_SYSCALL_BIT + 282)
13853 +#define __NR_timerfd_create (__X32_SYSCALL_BIT + 283)
13854 +#define __NR_eventfd (__X32_SYSCALL_BIT + 284)
13855 +#define __NR_fallocate (__X32_SYSCALL_BIT + 285)
13856 +#define __NR_timerfd_settime (__X32_SYSCALL_BIT + 286)
13857 +#define __NR_timerfd_gettime (__X32_SYSCALL_BIT + 287)
13858 +#define __NR_accept4 (__X32_SYSCALL_BIT + 288)
13859 +#define __NR_signalfd4 (__X32_SYSCALL_BIT + 289)
13860 +#define __NR_eventfd2 (__X32_SYSCALL_BIT + 290)
13861 +#define __NR_epoll_create1 (__X32_SYSCALL_BIT + 291)
13862 +#define __NR_dup3 (__X32_SYSCALL_BIT + 292)
13863 +#define __NR_pipe2 (__X32_SYSCALL_BIT + 293)
13864 +#define __NR_inotify_init1 (__X32_SYSCALL_BIT + 294)
13865 +#define __NR_perf_event_open (__X32_SYSCALL_BIT + 298)
13866 +#define __NR_fanotify_init (__X32_SYSCALL_BIT + 300)
13867 +#define __NR_fanotify_mark (__X32_SYSCALL_BIT + 301)
13868 +#define __NR_prlimit64 (__X32_SYSCALL_BIT + 302)
13869 +#define __NR_name_to_handle_at (__X32_SYSCALL_BIT + 303)
13870 +#define __NR_open_by_handle_at (__X32_SYSCALL_BIT + 304)
13871 +#define __NR_clock_adjtime (__X32_SYSCALL_BIT + 305)
13872 +#define __NR_syncfs (__X32_SYSCALL_BIT + 306)
13873 +#define __NR_setns (__X32_SYSCALL_BIT + 308)
13874 +#define __NR_getcpu (__X32_SYSCALL_BIT + 309)
13875 +#define __NR_kcmp (__X32_SYSCALL_BIT + 312)
13876 +#define __NR_finit_module (__X32_SYSCALL_BIT + 313)
13877 +#define __NR_sched_setattr (__X32_SYSCALL_BIT + 314)
13878 +#define __NR_sched_getattr (__X32_SYSCALL_BIT + 315)
13879 +#define __NR_renameat2 (__X32_SYSCALL_BIT + 316)
13880 +#define __NR_seccomp (__X32_SYSCALL_BIT + 317)
13881 +#define __NR_getrandom (__X32_SYSCALL_BIT + 318)
13882 +#define __NR_memfd_create (__X32_SYSCALL_BIT + 319)
13883 +#define __NR_kexec_file_load (__X32_SYSCALL_BIT + 320)
13885 +#define __NR_rt_sigaction (__X32_SYSCALL_BIT + 512)
13886 +#define __NR_rt_sigreturn (__X32_SYSCALL_BIT + 513)
13887 +#define __NR_ioctl (__X32_SYSCALL_BIT + 514)
13888 +#define __NR_readv (__X32_SYSCALL_BIT + 515)
13889 +#define __NR_writev (__X32_SYSCALL_BIT + 516)
13890 +#define __NR_recvfrom (__X32_SYSCALL_BIT + 517)
13891 +#define __NR_sendmsg (__X32_SYSCALL_BIT + 518)
13892 +#define __NR_recvmsg (__X32_SYSCALL_BIT + 519)
13893 +#define __NR_execve (__X32_SYSCALL_BIT + 520)
13894 +#define __NR_ptrace (__X32_SYSCALL_BIT + 521)
13895 +#define __NR_rt_sigpending (__X32_SYSCALL_BIT + 522)
13896 +#define __NR_rt_sigtimedwait (__X32_SYSCALL_BIT + 523)
13897 +#define __NR_rt_sigqueueinfo (__X32_SYSCALL_BIT + 524)
13898 +#define __NR_sigaltstack (__X32_SYSCALL_BIT + 525)
13899 +#define __NR_timer_create (__X32_SYSCALL_BIT + 526)
13900 +#define __NR_mq_notify (__X32_SYSCALL_BIT + 527)
13901 +#define __NR_kexec_load (__X32_SYSCALL_BIT + 528)
13902 +#define __NR_waitid (__X32_SYSCALL_BIT + 529)
13903 +#define __NR_set_robust_list (__X32_SYSCALL_BIT + 530)
13904 +#define __NR_get_robust_list (__X32_SYSCALL_BIT + 531)
13905 +#define __NR_vmsplice (__X32_SYSCALL_BIT + 532)
13906 +#define __NR_move_pages (__X32_SYSCALL_BIT + 533)
13907 +#define __NR_preadv (__X32_SYSCALL_BIT + 534)
13908 +#define __NR_pwritev (__X32_SYSCALL_BIT + 535)
13909 +#define __NR_rt_tgsigqueueinfo (__X32_SYSCALL_BIT + 536)
13910 +#define __NR_recvmmsg (__X32_SYSCALL_BIT + 537)
13911 +#define __NR_sendmmsg (__X32_SYSCALL_BIT + 538)
13912 +#define __NR_process_vm_readv (__X32_SYSCALL_BIT + 539)
13913 +#define __NR_process_vm_writev (__X32_SYSCALL_BIT + 540)
13914 +#define __NR_setsockopt (__X32_SYSCALL_BIT + 541)
13915 +#define __NR_getsockopt (__X32_SYSCALL_BIT + 542)
13916 +#define __NR_io_setup (__X32_SYSCALL_BIT + 543)
13917 +#define __NR_io_submit (__X32_SYSCALL_BIT + 544)
13920 +#define syscall_weak(name,wsym,sym) \
13922 +.type wsym,@function; \
13925 +.type sym,@function; \
13928 + mov $__NR_##name,%al; \
13929 + jmp __unified_syscall@PLT
13931 +#define syscall(name,sym) \
13933 +.type sym,@function; \
13936 +.ifge __NR_##name-256 ; \
13937 + mov $__NR_##name,%ax; \
13938 + jmp __unified_syscall_16bit@PLT; \
13940 + mov $__NR_##name,%al; \
13941 + jmp __unified_syscall@PLT; \
13946 +#define syscall_weak(name,wsym,sym) \
13948 +.type wsym,@function; \
13951 +.type sym,@function; \
13954 +.ifge __NR_##name-256 ; \
13955 + mov $__NR_##name,%ax; \
13956 + jmp __unified_syscall_16bit; \
13958 + mov $__NR_##name,%al; \
13959 + jmp __unified_syscall; \
13962 +#define syscall(name,sym) \
13964 +.type sym,@function; \
13967 +.ifge __NR_##name-256 ; \
13968 + mov $__NR_##name,%ax; \
13969 + jmp __unified_syscall_16bit; \
13971 + mov $__NR_##name,%al; \
13972 + jmp __unified_syscall; \
13975 diff -urN -x .git dietlibc-0.33/x86_64/clone.S dietlibc/x86_64/clone.S
13976 --- dietlibc-0.33/x86_64/clone.S 2005-01-31 12:53:34.000000000 +0000
13977 +++ dietlibc/x86_64/clone.S 2015-01-01 12:14:43.541605560 +0000
13979 movq %rcx,8(%rsi) /* thread parameter */
13980 movq %rdi,0(%rsi) /* thread function */
13983 + /* args to this function: args to syscall
13984 + ----------------------------------------------------
13985 + rdi = function to be called rdi = flags
13986 + rsi = child_stack rsi = child_stack
13987 + rdx = flags rdx = ptid
13988 + rcx = arg r10 = ctid
13989 + r8 = ptid r8 = regs
13994 + /* if CLONE_PARENT_SETTID is set, r8 goes into rdx */
13995 + test $0x100000,%rdi
13998 + /* if CLONE_SETTLS is set, r9 goes into r8 */
13999 + test $0x80000,%rdi
14002 + /* if CLONE_CHILD_SETTID is set, stack goes into r10 */
14003 + test $0x1000000,%rdi
14005 + movq 8(%rsp),%r10
14009 + /* if CLONE_SETTLS is set, r8 goes into r8 */
14010 + test $0x80000,%rdi
14012 +/* movq %r8,%r9 */
14014 + /* if CLONE_CHILD_SETTID is set, r9 goes into r10 */
14015 + test $0x1000000,%rdi
14021 + /* if CLONE_CHILD_SETTID is set, r8 goes into r10 */
14022 + test $0x1000000,%rdi
14029 movl $__NR_clone,%eax
14033 /* exit a thread */
14037 + jmp thrd_exit@PLT
14044 diff -urN -x .git dietlibc-0.33/x86_64/dyn_syscalls.S dietlibc/x86_64/dyn_syscalls.S
14045 --- dietlibc-0.33/x86_64/dyn_syscalls.S 2012-01-24 18:24:30.000000000 +0000
14046 +++ dietlibc/x86_64/dyn_syscalls.S 2015-01-01 12:14:43.541605560 +0000
14048 .global __unified_syscall_16bit
14053 __unified_syscall_16bit:
14061 + call __errno_location
14062 + .hidden __errno_location
14064 call __errno_location@PLT
14070 #include "../syscalls.s/epoll_create.S"
14071 #include "../syscalls.s/epoll_ctl.S"
14072 #include "../syscalls.s/epoll_wait.S"
14073 -#include "../syscalls.s/errno.S"
14074 #include "../syscalls.s/execve.S"
14075 #include "../syscalls.s/fchdir.S"
14076 #include "../syscalls.s/fchmod.S"
14077 @@ -141,7 +145,6 @@
14078 #include "../syscalls.s/n_sigprocmask.S"
14079 #include "../syscalls.s/n_sigsuspend.S"
14080 #include "../syscalls.s/nanosleep.S"
14081 -#include "../syscalls.s/nice.S"
14082 #include "../syscalls.s/open.S"
14083 #include "../syscalls.s/pause.S"
14084 #include "../syscalls.s/personality.S"
14085 @@ -331,3 +334,5 @@
14086 #include "x86_64/gettimeofday.S"
14088 #include "syscalls.s/__guard.S"
14090 + .section .note.GNU-stack,"",@progbits
14091 diff -urN -x .git dietlibc-0.33/x86_64/getcontext.S dietlibc/x86_64/getcontext.S
14092 --- dietlibc-0.33/x86_64/getcontext.S 1970-01-01 00:00:00.000000000 +0000
14093 +++ dietlibc/x86_64/getcontext.S 2015-01-01 12:14:43.541605560 +0000
14095 +#include "syscalls.h"
14098 +.global getcontext
14099 +.type getcontext,@function
14100 +/* store current CPU context into struct ucontext* */
14102 + /* the registers are in uc_mcontext, which starts at offset 40 */
14103 + movq %r8,40(%rdi)
14104 + movq %r9,48(%rdi)
14105 +// movq %r10,56(%rdi)
14106 +// movq %r11,64(%rdi)
14107 + movq %r12,72(%rdi)
14108 + movq %r13,80(%rdi)
14109 + movq %r14,88(%rdi)
14110 + movq %r15,96(%rdi)
14111 + movq %rdi,104(%rdi) /* what a useless statement :-) */
14112 + movq %rsi,112(%rdi)
14113 + movq %rbp,120(%rdi)
14114 + movq %rbx,128(%rdi)
14115 + movq %rdx,136(%rdi)
14116 + movq $0,144(%rdi) /* store 0 as value of rax because that's the return value of the function */
14117 + movq %rcx,152(%rdi)
14118 + leaq 8(%rsp),%rax
14119 + movq %rax,160(%rdi)
14121 + movq %rax,168(%rdi) /* store function return address as rip */
14123 + movq %rax,176(%rdi)
14124 + /* valgrind dies if we use these instructions */
14125 +// movw %cs,184(%rdi)
14126 +// movw %gs,186(%rdi)
14127 +// movw %fs,188(%rdi)
14128 + /* write nothing to err (192) and trapno (200) */
14130 + leaq 424(%rdi),%rax
14131 + movq %rax,224(%rdi)
14134 + stmxcsr 448(%rdi)
14136 + /* now call sigprocmask(SIG_BLOCK, NULL, &uc->uc_sigmask) */
14137 + leaq 296(%rdi),%rdx
14141 +.size getcontext, .-getcontext
14142 diff -urN -x .git dietlibc-0.33/x86_64/gettimeofday.S dietlibc/x86_64/gettimeofday.S
14143 --- dietlibc-0.33/x86_64/gettimeofday.S 2012-01-24 18:24:30.000000000 +0000
14144 +++ dietlibc/x86_64/gettimeofday.S 2015-01-01 12:14:43.541605560 +0000
14146 +#include "dietfeatures.h"
14147 +#include "syscalls.h"
14150 .global gettimeofday
14151 .type gettimeofday,@function
14153 +#ifdef WANT_VALGRIND_SUPPORT
14155 + mov __valgrind@GOTPCREL(%rip), %rax
14158 + cmpb $1, __valgrind(%rip)
14162 movq gtod(%rip), %rax
14165 @@ -11,13 +23,25 @@
14170 + movq __vdso@GOTPCREL(%rip), %rax
14172 + movq funcname@GOTPCREL(%rip), %rsi
14173 + call vdso_dlsym@PLT
14175 movq __vdso(%rip),%rdi
14176 movq $funcname, %rsi
14183 +#ifdef WANT_VALGRIND_SUPPORT
14185 + mov $__NR_gettimeofday, %al
14186 + jmp __unified_syscall
14189 .size gettimeofday,.Lhere-gettimeofday
14191 diff -urN -x .git dietlibc-0.33/x86_64/Makefile.add dietlibc/x86_64/Makefile.add
14192 --- dietlibc-0.33/x86_64/Makefile.add 2012-01-24 18:24:30.000000000 +0000
14193 +++ dietlibc/x86_64/Makefile.add 2015-01-01 12:14:43.541605560 +0000
14195 -CFLAGS := -Os -fstrict-aliasing -momit-leaf-frame-pointer -mfancy-math-387
14196 +ifeq ($(CC),clang)
14197 +CFLAGS := -Os -fstrict-aliasing -momit-leaf-frame-pointer $(EXTRACFLAGS)
14199 +CFLAGS := -Os -fstrict-aliasing -momit-leaf-frame-pointer -mfancy-math-387 -fPIC -fvisibility=hidden $(EXTRACFLAGS)
14201 VPATH := x86_64:syscalls.s:$(VPATH)
14202 -LIBOBJ += $(OBJDIR)/arch_prctl.o $(OBJDIR)/__CAS.o
14203 +LIBOBJ += $(OBJDIR)/arch_prctl.o $(OBJDIR)/__CAS.o $(OBJDIR)/__munmap_and_exit.o $(OBJDIR)/getcontext.o
14204 +LIBOBJ += $(OBJDIR)/setcontext.o
14205 diff -urN -x .git dietlibc-0.33/x86_64/__munmap_and_exit.S dietlibc/x86_64/__munmap_and_exit.S
14206 --- dietlibc-0.33/x86_64/__munmap_and_exit.S 1970-01-01 00:00:00.000000000 +0000
14207 +++ dietlibc/x86_64/__munmap_and_exit.S 2015-01-01 12:14:43.541605560 +0000
14209 +#include "syscalls.h"
14212 +.global __munmap_and_exit
14213 +.type __munmap_and_exit,@function
14214 +__munmap_and_exit:
14215 + mov $__NR_munmap,%eax
14217 + mov $__NR_exit,%eax
14221 +.size __munmap_and_exit, .Lhere-__munmap_and_exit
14222 diff -urN -x .git dietlibc-0.33/x86_64/setcontext.S dietlibc/x86_64/setcontext.S
14223 --- dietlibc-0.33/x86_64/setcontext.S 1970-01-01 00:00:00.000000000 +0000
14224 +++ dietlibc/x86_64/setcontext.S 2015-01-01 12:14:43.541605560 +0000
14226 +#include "syscalls.h"
14230 +.global __setcontext_trampoline
14231 +.type __setcontext_trampoline,@function
14232 +__setcontext_trampoline:
14234 + /* fall through */
14235 + .size __setcontext_trampoline, .-__setcontext_trampoline
14237 +.global setcontext
14238 +.type setcontext,@function
14239 +/* load current CPU context from struct ucontext* */
14241 + /* first restore the signal mask, call sigprocmask(SIG_SETMASK,&uc->uc_sigmask,NULL) */
14243 + leaq 296(%rdi),%rsi
14251 + /* now the floating point context */
14252 + movq 224(%rdi),%rax
14254 + ldmxcsr 448(%rdi)
14256 + /* the registers are in uc_mcontext, which starts at offset 40 */
14257 + movq 40(%rdi),%r8
14258 + movq 48(%rdi),%r9
14259 + movq 72(%rdi),%r12
14260 + movq 80(%rdi),%r13
14261 + movq 88(%rdi),%r14
14262 + movq 96(%rdi),%r15
14264 + movq 112(%rdi),%rsi
14265 + movq 120(%rdi),%rbp
14266 + movq 128(%rdi),%rbx
14267 + movq 136(%rdi),%rdx
14268 + movq 152(%rdi),%rcx
14269 + movq 160(%rdi),%rsp
14270 + pushq 168(%rdi) /* push return value so ret goes to the right place */
14272 +// movw 186(%rdi),%gs
14273 +// movw 188(%rdi),%fs
14275 + movq 104(%rdi),%rdi
14281 +.size setcontext, .-setcontext
14282 diff -urN -x .git dietlibc-0.33/x86_64/start.S dietlibc/x86_64/start.S
14283 --- dietlibc-0.33/x86_64/start.S 2012-11-02 11:17:28.000000000 +0000
14284 +++ dietlibc/x86_64/start.S 2015-01-01 12:14:43.541605560 +0000
14285 @@ -12,11 +12,28 @@
14287 leaq 8(%rsi,%rdi,8),%rdx /* %rdx = envp = (8*rdi)+%rsi+8 */
14290 +#ifdef WANT_ELFINFO
14292 + movq environ@GOTPCREL(%rip), %rax
14294 + leaq environ(%rip), %rax
14296 + movq %rdx, (%rax) /* environ */
14298 +1: add $8, %rdx /* increment envp */
14299 + cmpq $0, -8(%rdx) /* load envp[-1] */
14300 + jne 1b /* ... until envp[-1]==NULL */
14302 + movq %rdx, 8(%rax) /* __elfinfo */
14305 movq environ@GOTPCREL(%rip), %rax
14308 movq %rdx, environ(%rip)
14316 #ifdef WANT_DYNAMIC
14318 + .hidden _dyn_start
14320 call CALL_IN_STARTCODE
14321 + .hidden CALL_IN_STARTCODE
14325 @@ -48,14 +67,22 @@
14327 movq %rax, %rdi /* return value */
14335 #if defined(__ILP32__)
14336 - xor %rax,%rax /* do exit inline with x64 syscall number so it also works if the kernel does not have x32 support */
14338 + mov $SYS_exit,%eax
14348 .size _start,.Lstart-_start
14350 + .section .note.GNU-stack,"",@progbits
14351 diff -urN -x .git dietlibc-0.33/x86_64/syscalls.h dietlibc/x86_64/syscalls.h
14352 --- dietlibc-0.33/x86_64/syscalls.h 2012-01-24 18:24:30.000000000 +0000
14353 +++ dietlibc/x86_64/syscalls.h 2015-01-01 12:14:43.541605560 +0000
14354 @@ -349,6 +349,24 @@
14355 #define __NR_fanotify_init 300
14356 #define __NR_fanotify_mark 301
14357 #define __NR_prlimit64 302
14358 +#define __NR_name_to_handle_at 303
14359 +#define __NR_open_by_handle_at 304
14360 +#define __NR_clock_adjtime 305
14361 +#define __NR_syncfs 306
14362 +#define __NR_sendmmsg 307
14363 +#define __NR_setns 308
14364 +#define __NR_getcpu 309
14365 +#define __NR_process_vm_readv 310
14366 +#define __NR_process_vm_writev 311
14367 +#define __NR_kcmp 312
14368 +#define __NR_finit_module 313
14369 +#define __NR_sched_setattr 314
14370 +#define __NR_sched_getattr 315
14371 +#define __NR_renameat2 316
14372 +#define __NR_seccomp 317
14373 +#define __NR_getrandom 318
14374 +#define __NR_memfd_create 319
14375 +#define __NR_kexec_file_load 320
14378 #define syscall_weak(name,wsym,sym) \
14379 @@ -359,8 +377,13 @@
14380 .type sym,@function; \
14383 +.ifge __NR_##name-256 ; \
14384 + mov $__NR_##name,%ax; \
14385 + jmp __unified_syscall_16bit@PLT; \
14387 mov $__NR_##name,%al; \
14388 - jmp __unified_syscall@PLT
14389 + jmp __unified_syscall@PLT; \
14392 #define syscall(name,sym) \
14394 @@ -369,10 +392,10 @@
14396 .ifge __NR_##name-256 ; \
14397 mov $__NR_##name,%ax; \
14398 - jmp __unified_syscall_16bit@PLT; \
14399 + jmp __unified_syscall_16bit@PLT; \
14401 mov $__NR_##name,%al; \
14402 - jmp __unified_syscall@PLT; \
14403 + jmp __unified_syscall@PLT; \
14407 @@ -387,10 +410,10 @@
14409 .ifge __NR_##name-256 ; \
14410 mov $__NR_##name,%ax; \
14411 - jmp __unified_syscall_16bit; \
14412 + jmp __unified_syscall_16bit; \
14414 mov $__NR_##name,%al; \
14415 - jmp __unified_syscall; \
14416 + jmp __unified_syscall; \
14419 #define syscall(name,sym) \
14420 diff -urN -x .git dietlibc-0.33/x86_64/__time.S dietlibc/x86_64/__time.S
14421 --- dietlibc-0.33/x86_64/__time.S 1970-01-01 00:00:00.000000000 +0000
14422 +++ dietlibc/x86_64/__time.S 2015-01-01 12:14:43.541605560 +0000
14424 +/* implement time(2) via gettimeofday(2) on x86-64 because gettimeofday
14425 + is a vsyscall (i.e. no actual switch to kernel mode) */
14428 +.type time,@function
14430 + mov $0xffffffffff600400,%rax
14434 + .size time,.Lhere-time
14435 diff -urN -x .git dietlibc-0.33/x86_64/time.S dietlibc/x86_64/time.S
14436 --- dietlibc-0.33/x86_64/time.S 2012-01-24 18:24:30.000000000 +0000
14437 +++ dietlibc/x86_64/time.S 2015-01-01 12:14:43.541605560 +0000
14439 -/* implement time(2) via gettimeofday(2) on x86-64 because gettimeofday
14440 - is a vsyscall (i.e. no actual switch to kernel mode) */
14443 -.type time,@function
14445 - mov $0xffffffffff600400,%rax
14449 - .size time,.Lhere-time
14450 +/* avoid empty source file */
14451 diff -urN -x .git dietlibc-0.33/x86_64/unified.S dietlibc/x86_64/unified.S
14452 --- dietlibc-0.33/x86_64/unified.S 2012-11-02 11:17:29.000000000 +0000
14453 +++ dietlibc/x86_64/unified.S 2015-01-01 12:14:43.541605560 +0000
14454 @@ -13,12 +13,14 @@
14455 .global __error_unified_syscall
14456 .global __unified_syscall
14457 .global __unified_syscall_16bit
14458 +.global __unified_syscall_lp64
14461 __unified_syscall_16bit:
14463 #if defined(__ILP32__)
14464 or $0x40000000, %eax
14465 +__unified_syscall_lp64:
14472 call __errno_location
14474 + .hidden __errno_location