Last active
April 4, 2016 21:05
-
-
Save chris-se/e01aa2cda9e8b75943e7610a7f3d71ec to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: lib/strcpy.c | |
=================================================================== | |
RCS file: /cvs/dietlibc/lib/strcpy.c,v | |
retrieving revision 1.5 | |
diff -u -p -r1.5 strcpy.c | |
--- lib/strcpy.c 19 Feb 2008 00:28:13 -0000 1.5 | |
+++ lib/strcpy.c 4 Apr 2016 20:49:53 -0000 | |
@@ -3,6 +3,10 @@ | |
#include "dietfeatures.h" | |
#include "dietstring.h" | |
+#ifdef WANT_VALGRIND_SUPPORT | |
+extern int __valgrind; | |
+#endif | |
+ | |
char * | |
strcpy (char *s1, const char *s2) | |
{ | |
@@ -14,7 +18,11 @@ strcpy (char *s1, const char *s2) | |
int tmp; | |
unsigned long l; | |
- if (UNALIGNED(s1, s2)) { | |
+ if (UNALIGNED(s1, s2) | |
+#ifdef WANT_VALGRIND_SUPPORT | |
+ || __unlikely(__valgrind) | |
+#endif | |
+ ) { | |
while ((*s1++ = *s2++)); | |
return (res); | |
} | |
Index: lib/strcmp.c | |
=================================================================== | |
RCS file: /cvs/dietlibc/lib/strcmp.c,v | |
retrieving revision 1.6 | |
diff -u -p -r1.6 strcmp.c | |
--- lib/strcmp.c 19 Feb 2008 00:28:13 -0000 1.6 | |
+++ lib/strcmp.c 4 Apr 2016 20:49:53 -0000 | |
@@ -3,6 +3,10 @@ | |
#include "dietfeatures.h" | |
#include "dietstring.h" | |
+#ifdef WANT_VALGRIND_SUPPORT | |
+extern int __valgrind; | |
+#endif | |
+ | |
int | |
strcmp (const char *s1, const char *s2) | |
{ | |
@@ -15,7 +19,11 @@ strcmp (const char *s1, const char *s2) | |
unsigned long l1, l2; | |
int tmp; | |
- if (UNALIGNED(s1, s2)) { | |
+ if (UNALIGNED(s1, s2) | |
+#ifdef WANT_VALGRIND_SUPPORT | |
+ || __unlikely(__valgrind) | |
+#endif | |
+ ) { | |
while (*s1 && *s1 == *s2) s1++, s2++; | |
return (*s1 - *s2); | |
} | |
Index: lib/strlen.c | |
=================================================================== | |
RCS file: /cvs/dietlibc/lib/strlen.c,v | |
retrieving revision 1.4 | |
diff -u -p -r1.4 strlen.c | |
--- lib/strlen.c 19 Feb 2008 00:28:13 -0000 1.4 | |
+++ lib/strlen.c 4 Apr 2016 20:49:53 -0000 | |
@@ -22,6 +22,10 @@ typedef uint32_t word_t; | |
static word_t const magic = (word_t)(0x0101010101010101ull); | |
+#ifdef WANT_VALGRIND_SUPPORT | |
+extern int __valgrind; | |
+#endif | |
+ | |
size_t strlen(const char *s) | |
{ | |
const char *t = s; | |
@@ -30,6 +34,14 @@ size_t strlen(const char *s) | |
if (__unlikely(!s)) return 0; | |
+#ifdef WANT_VALGRIND_SUPPORT | |
+ if (__unlikely(__valgrind)) { | |
+ register size_t i; | |
+ for (i=0; __likely(*s); ++s) ++i; | |
+ return i; | |
+ } | |
+#endif | |
+ | |
/* Byte compare up until word boundary */ | |
for (; ((unsigned long) t & (sizeof(magic)-1)); t++) | |
if (!*t) return t - s; | |
Index: arm/strlen.S | |
=================================================================== | |
RCS file: /cvs/dietlibc/arm/strlen.S,v | |
retrieving revision 1.6 | |
diff -u -p -r1.6 strlen.S | |
--- arm/strlen.S 19 Apr 2014 15:07:33 -0000 1.6 | |
+++ arm/strlen.S 4 Apr 2016 20:49:53 -0000 | |
@@ -1,6 +1,8 @@ | |
#include "dietfeatures.h" | |
#include "arm-features.h" | |
+.extern __valgrind | |
+ | |
FUNC_START strlen | |
#if 0 | |
teq a1, #0 @ is string pointer NULL ?? | |
@@ -8,6 +10,11 @@ FUNC_START strlen | |
#endif | |
#ifndef WANT_SMALL_STRING_ROUTINES | |
+#ifdef WANT_VALGRIND_SUPPORT | |
+ ldr ip, =__valgrind | |
+ bne .Lvalgrind | |
+#endif | |
+ | |
ands a3, a1, #3 | |
ldr ip, .Lmagic | |
mov a2, a1 | |
@@ -46,13 +53,21 @@ FUNC_START strlen | |
addeq a1, a1, #1 | |
#endif | |
sub a1, a1, a2 | |
-#else | |
+ | |
+#ifdef WANT_VALGRIND_SUPPORT | |
+ RET | |
+ | |
+.Lvalgrind: | |
+#endif | |
+#endif | |
+ | |
+#if defined(WANT_SMALL_STRING_ROUTINES) || defined(WANT_VALGRIND_SUPPORT) | |
ldrb a3, [a1], #1 | |
mov a2, a1 | |
-.Lloop: | |
+.Lslowloop: | |
tst a3, #255 | |
ldrneb a3, [a1], #1 | |
- bne .Lloop | |
+ bne .Lslowloop | |
sub a1, a1, a2 | |
#endif | |
Index: arm/strcpy.S | |
=================================================================== | |
RCS file: /cvs/dietlibc/arm/strcpy.S,v | |
retrieving revision 1.4 | |
diff -u -p -r1.4 strcpy.S | |
--- arm/strcpy.S 19 Apr 2014 15:07:33 -0000 1.4 | |
+++ arm/strcpy.S 4 Apr 2016 20:49:53 -0000 | |
@@ -3,6 +3,11 @@ | |
FUNC_START strcpy | |
#ifndef WANT_SMALL_STRING_ROUTINES | |
+#ifdef WANT_VALGRIND_SUPPORT | |
+ ldr ip, =__valgrind | |
+ bne .Lvalgrind | |
+#endif | |
+ | |
mov ip, r0 | |
ands r2, r1, #3 | |
ldr r3, [r1, -r2]! | |
@@ -49,14 +54,22 @@ FUNC_START strcpy | |
strb r3, [ip], #1 | |
ldrne r3, [r1, #4]! | |
#endif | |
-#else | |
+ bne .Lloop | |
+#ifdef WANT_VALGRIND_SUPPORT | |
+ RET | |
+ | |
+.Lvalgrind: | |
+#endif | |
+#endif | |
+ | |
+#if defined(WANT_SMALL_STRING_ROUTINES) || defined(WANT_VALGRIND_SUPPORT) | |
ldrb r2, [r1], #1 | |
mov r3, r0 | |
-.Lloop: | |
+.Lslowloop: | |
strb r2, [r3], #1 | |
tst r2, #255 | |
ldrneb r2, [r1], #1 | |
+ bne .Lslowloop | |
#endif | |
- bne .Lloop | |
RET | |
FUNC_END strcpy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: syscalls.s/ftruncate64.S | |
=================================================================== | |
RCS file: /cvs/dietlibc/syscalls.s/ftruncate64.S,v | |
retrieving revision 1.1 | |
diff -u -p -r1.1 ftruncate64.S | |
--- syscalls.s/ftruncate64.S 5 May 2002 21:44:08 -0000 1.1 | |
+++ syscalls.s/ftruncate64.S 4 Apr 2016 20:27:02 -0000 | |
@@ -3,7 +3,7 @@ | |
#ifdef __NR_ftruncate64 | |
#ifdef WANT_LARGEFILE_BACKCOMPAT | |
-syscall(ftruncate64,__dietlibc_ftruncate64) | |
+syscall_weak(ftruncate64,__dietlibc_ftruncate64_syscall,__dietlibc_ftruncate64) | |
#else | |
syscall(ftruncate64,ftruncate64) | |
#endif | |
Index: syscalls.s/truncate64.S | |
=================================================================== | |
RCS file: /cvs/dietlibc/syscalls.s/truncate64.S,v | |
retrieving revision 1.2 | |
diff -u -p -r1.2 truncate64.S | |
--- syscalls.s/truncate64.S 5 May 2002 21:49:30 -0000 1.2 | |
+++ syscalls.s/truncate64.S 4 Apr 2016 20:27:02 -0000 | |
@@ -3,7 +3,7 @@ | |
#ifdef __NR_truncate64 | |
#ifdef WANT_LARGEFILE_BACKCOMPAT | |
-syscall(truncate64,__dietlibc_truncate64) | |
+syscall_weak(truncate64,__dietlibc_truncate64_syscall,__dietlibc_truncate64) | |
#else | |
syscall(truncate64,truncate64) | |
#endif | |
Index: parisc/ftruncate64.S | |
=================================================================== | |
RCS file: parisc/ftruncate64.S | |
diff -N parisc/ftruncate64.S | |
--- /dev/null 1 Jan 1970 00:00:00 -0000 | |
+++ parisc/ftruncate64.S 4 Apr 2016 20:27:02 -0000 | |
@@ -0,0 +1,12 @@ | |
+#include "parisc/syscalls.h" | |
+ | |
+.text | |
+.type __dietlibc_ftruncate64,@function | |
+.globl __dietlibc_ftruncate64 | |
+.export __dietlibc_ftruncate64 | |
+__dietlibc_ftruncate64: | |
+#if !defined(__LP64__) | |
+ copy %arg3,%arg1 | |
+#endif | |
+ b __unified_syscall | |
+ ldi __NR_ftruncate64, %r20 | |
Index: parisc/truncate64.S | |
=================================================================== | |
RCS file: parisc/truncate64.S | |
diff -N parisc/truncate64.S | |
--- /dev/null 1 Jan 1970 00:00:00 -0000 | |
+++ parisc/truncate64.S 4 Apr 2016 20:27:02 -0000 | |
@@ -0,0 +1,12 @@ | |
+#include "parisc/syscalls.h" | |
+ | |
+.text | |
+.type __dietlibc_truncate64,@function | |
+.globl __dietlibc_truncate64 | |
+.export __dietlibc_truncate64 | |
+__dietlibc_truncate64: | |
+#if !defined(__LP64__) | |
+ copy %arg3,%arg1 | |
+#endif | |
+ b __unified_syscall | |
+ ldi __NR_truncate64, %r20 | |
Index: parisc/select.S | |
=================================================================== | |
RCS file: parisc/select.S | |
diff -N parisc/select.S | |
--- /dev/null 1 Jan 1970 00:00:00 -0000 | |
+++ parisc/select.S 4 Apr 2016 20:27:02 -0000 | |
@@ -0,0 +1,3 @@ | |
+#include "syscalls.h" | |
+ | |
+syscall5(select, select); | |
Index: parisc/semctl.S | |
=================================================================== | |
RCS file: parisc/semctl.S | |
diff -N parisc/semctl.S | |
--- /dev/null 1 Jan 1970 00:00:00 -0000 | |
+++ parisc/semctl.S 4 Apr 2016 20:27:02 -0000 | |
@@ -0,0 +1,3 @@ | |
+#include "syscalls.h" | |
+ | |
+syscall(semctl,semctl) | |
Index: parisc/semget.S | |
=================================================================== | |
RCS file: parisc/semget.S | |
diff -N parisc/semget.S | |
--- /dev/null 1 Jan 1970 00:00:00 -0000 | |
+++ parisc/semget.S 4 Apr 2016 20:27:02 -0000 | |
@@ -0,0 +1,3 @@ | |
+#include "syscalls.h" | |
+ | |
+syscall(semget,semget) | |
Index: parisc/semop.S | |
=================================================================== | |
RCS file: parisc/semop.S | |
diff -N parisc/semop.S | |
--- /dev/null 1 Jan 1970 00:00:00 -0000 | |
+++ parisc/semop.S 4 Apr 2016 20:27:02 -0000 | |
@@ -0,0 +1,3 @@ | |
+#include "syscalls.h" | |
+ | |
+syscall(semop,semop) | |
Index: parisc/start.S | |
=================================================================== | |
RCS file: /cvs/dietlibc/parisc/start.S,v | |
retrieving revision 1.5 | |
diff -u -p -r1.5 start.S | |
--- parisc/start.S 4 Apr 2006 05:35:14 -0000 1.5 | |
+++ parisc/start.S 4 Apr 2016 20:27:02 -0000 | |
@@ -46,7 +46,7 @@ _start: | |
bl CALL_IN_STARTCODE, %rp | |
#endif | |
ldo R%$global$(%dp), %dp | |
- b _exit | |
+ b exit | |
or %r28, %r28, %r26 | |
.EXIT | |
.PROCEND | |
Index: include/errno.h | |
=================================================================== | |
RCS file: /cvs/dietlibc/include/errno.h,v | |
retrieving revision 1.24 | |
diff -u -p -r1.24 errno.h | |
--- include/errno.h 24 Mar 2014 08:19:56 -0000 1.24 | |
+++ include/errno.h 4 Apr 2016 20:27:02 -0000 | |
@@ -550,7 +550,7 @@ | |
#define EALREADY 244 /* Operation already in progress */ | |
#define EINPROGRESS 245 /* Operation now in progress */ | |
-#define EWOULDBLOCK 246 /* Operation would block (Linux returns EAGAIN) */ | |
+#define EWOULDBLOCK EAGAIN /* Operation would block (Linux returns EAGAIN) */ | |
#define ENOTEMPTY 247 /* Directory not empty */ | |
#define ENAMETOOLONG 248 /* File name too long */ | |
#define ELOOP 249 /* Too many symbolic links encountered */ | |
Index: include/signal.h | |
=================================================================== | |
RCS file: /cvs/dietlibc/include/signal.h,v | |
retrieving revision 1.56 | |
diff -u -p -r1.56 signal.h | |
--- include/signal.h 10 Oct 2014 14:54:29 -0000 1.56 | |
+++ include/signal.h 4 Apr 2016 20:27:02 -0000 | |
@@ -97,9 +97,9 @@ __BEGIN_DECLS | |
#define SIGXCPU 30 | |
#define SIGXFSZ 31 | |
#elif defined(__hppa__) | |
-#define SIGEMT 7 | |
+#define SIGSTKFLT 7 | |
#define SIGBUS 10 | |
-#define SIGSYS 12 | |
+#define SIGXCPU 12 | |
#define SIGUSR1 16 | |
#define SIGUSR2 17 | |
#define SIGCHLD 18 | |
@@ -114,12 +114,10 @@ __BEGIN_DECLS | |
#define SIGTTIN 27 | |
#define SIGTTOU 28 | |
#define SIGURG 29 | |
-#define SIGLOST 30 | |
+#define SIGXFSZ 30 | |
#define SIGUNUSED 31 | |
-#define SIGRESERVE SIGUNUSE | |
-#define SIGXCPU 33 | |
-#define SIGXFSZ 34 | |
-#define SIGSTKFLT 36 | |
+#define SIGRESERVE SIGUNUSED | |
+#define SIGSYS 31 | |
#else | |
#error signal layout not yet known | |
@@ -129,12 +127,8 @@ __BEGIN_DECLS | |
#define SIGPOLL SIGIO | |
/* These should not be considered constants from userland. */ | |
-#ifdef __hppa__ | |
-#define SIGRTMIN 37 | |
-#else | |
#define SIGLOST SIGPWR | |
#define SIGRTMIN 32 | |
-#endif | |
#define SIGRTMAX (_NSIG-1) | |
/* SA_FLAGS values: */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: libm/gamma.c | |
=================================================================== | |
RCS file: /cvs/dietlibc/libm/gamma.c,v | |
retrieving revision 1.3 | |
diff -u -p -r1.3 gamma.c | |
--- libm/gamma.c 15 Mar 2005 08:51:23 -0000 1.3 | |
+++ libm/gamma.c 4 Apr 2016 20:46:06 -0000 | |
@@ -33,6 +33,31 @@ Return value gamma returns a value in | |
#include <stdlib.h> | |
#include <math.h> | |
+#if defined(__powerpc__) | |
+/* gcc on PowerPC has a bug that it doesn't consider expressions that | |
+ * contain long doubles constant, so they can't be used as initializers. | |
+ * This has been the case since at least gcc-4.1, but is still present | |
+ * in gcc-5.3. This is because long double on ppc is really weird (it's | |
+ * 128bit, but NOT a IEEE 754 quad) and gcc doesn't really know how to | |
+ * deal with it and just generates native code to create these values | |
+ * at run time whenever it sees long double expressions. Use double | |
+ * initializers for now. See also: | |
+ * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=26374 | |
+ */ | |
+#define B0 + 1.0/ 6/ 1/ 2 | |
+#define B1 - 1.0/ 30/ 3/ 4 | |
+#define B2 + 1.0/ 42/ 5/ 6 | |
+#define B3 - 1.0/ 30/ 7/ 8 | |
+#define B4 + 5.0/ 66/ 9/10 | |
+#define B5 - 691.0/2730/11/12 | |
+#define B6 + 7.0/ 6/13/14 | |
+#define B7 - 3617.0/ 510/15/16 | |
+#define B8 + 43867.0/ 798/17/18 | |
+#define B9 - 174611.0/ 330/19/20 | |
+#define B10 + 854513.0/ 138/21/22 | |
+#define B11 - 236364091.0/2730/23/24 | |
+#define B12 + 8553103.0/ 6/25/26 | |
+#else | |
#define B0 + 1.0l/ 6/ 1/ 2 | |
#define B1 - 1.0l/ 30/ 3/ 4 | |
#define B2 + 1.0l/ 42/ 5/ 6 | |
@@ -46,6 +71,7 @@ Return value gamma returns a value in | |
#define B10 + 854513.0l/ 138/21/22 | |
#define B11 - 236364091.0l/2730/23/24 | |
#define B12 + 8553103.0l/ 6/25/26 | |
+#endif | |
static const double coeff[] = { B0, B1, B2, B3, B4, B5, B6, B7, B8, B9, B10 }; | |
int signgam; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: arm/__longjmp.S | |
=================================================================== | |
RCS file: /cvs/dietlibc/arm/__longjmp.S,v | |
retrieving revision 1.5 | |
diff -u -p -r1.5 __longjmp.S | |
--- arm/__longjmp.S 29 Mar 2016 15:56:32 -0000 1.5 | |
+++ arm/__longjmp.S 4 Apr 2016 20:46:44 -0000 | |
@@ -5,7 +5,7 @@ FUNC_START __longjmp | |
movs r0, r1 | |
moveq r0, #1 | |
#ifndef __SOFTFP__ | |
-# if __ARM_ARCH__ == 6 | |
+# if __ARM_ARCH__ >= 6 | |
vldm ip!, {d0-d15} | |
# ifdef __ARM_NEON__ | |
vldm ip!, {d16-d31} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: lib/stackgap-common.h | |
=================================================================== | |
RCS file: /cvs/dietlibc/lib/stackgap-common.h,v | |
retrieving revision 1.1 | |
diff -u -p -r1.1 stackgap-common.h | |
--- lib/stackgap-common.h 17 Mar 2016 13:09:51 -0000 1.1 | |
+++ lib/stackgap-common.h 4 Apr 2016 20:48:14 -0000 | |
@@ -97,6 +97,20 @@ static void findtlsdata(long* auxvec) { | |
#if defined(WANT_SSP) || defined(WANT_TLS) | |
tcbhead_t* __tcb_mainthread; | |
+/* Newer gcc versions optimize assignments to register variables out | |
+ * unless they are declared as global variables. register globals | |
+ * aren't symbols, so hidden visibility is not required. */ | |
+#if defined(__ia64__) || defined(__powerpc64__) | |
+register tcbhead_t * __thread_self __asm("r13"); | |
+#define GLOBAL_TLS_REGISTER 1 | |
+#elif defined(__powerpc__) | |
+register tcbhead_t * __thread_self __asm("r2"); | |
+#define GLOBAL_TLS_REGISTER 1 | |
+#elif defined(__sparc__) | |
+register tcbhead_t * __thread_self __asm("%g7"); | |
+#define GLOBAL_TLS_REGISTER 1 | |
+#endif | |
+ | |
void __setup_tls(tcbhead_t*); | |
void __setup_tls(tcbhead_t* mainthread) { | |
@@ -129,22 +143,25 @@ void __setup_tls(tcbhead_t* mainthread) | |
#elif defined(__alpha__) || defined(__s390__) | |
__builtin_set_thread_pointer(mainthread); | |
-#elif defined(__ia64__) || defined(__powerpc64__) | |
- register tcbhead_t* __thread_self __asm__("r13"); | |
- __thread_self=mainthread; | |
-#elif defined(__powerpc__) | |
- /* __thread_self=mainthread is optimized out by gcc 5 with -Os | |
- * on PPC */ | |
- register tcbhead_t* __thread_self __asm__("r2"); | |
- __asm__ volatile ("addi %0,%1,0" : "=r"(__thread_self) : "r"(mainthread)); | |
-#elif defined(__sparc__) | |
- register tcbhead_t* __thread_self __asm("%g7"); | |
+#elif defined(GLOBAL_TLS_REGISTER) | |
__thread_self=mainthread; | |
#elif defined(__mips__) | |
set_thread_area((char*)(void *)mainthread); | |
#elif defined(__arm__) | |
extern void __arm_set_tls(void*); | |
__arm_set_tls(mainthread); | |
+#elif defined(__hppa__) | |
+ /* control register 27 is used as thread pointer on PA-RISC Linux, | |
+ * but it can only be set from Ring0. The Linux kernel provides | |
+ * privileged code to set this register, so call that. (cf. syscalls, | |
+ * which branch to 0x100(%%sr2, %%r0), instead.) PA-RISC has | |
+ * 1-instruction delayed branching. The register may be read by any | |
+ * code however (using mfctl %cr27, %rXX). r26 is used as input for | |
+ * the kernel code, r31 is the return address pointer set by the | |
+ * branch instruction, so clobber both. */ | |
+ asm volatile ("ble 0xe0(%%sr2, %%r0)\n\t" | |
+ "copy %0, %%r26" | |
+ :: "r" (mainthread) : "r26", "r31"); | |
#else | |
#warning "no idea how to enable TLS on this platform, edit lib/stackgap.c" | |
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: lib/strlen.c | |
=================================================================== | |
RCS file: /cvs/dietlibc/lib/strlen.c,v | |
retrieving revision 1.4 | |
diff -u -p -r1.4 strlen.c | |
--- lib/strlen.c 19 Feb 2008 00:28:13 -0000 1.4 | |
+++ lib/strlen.c 4 Apr 2016 20:50:20 -0000 | |
@@ -22,26 +22,29 @@ typedef uint32_t word_t; | |
static word_t const magic = (word_t)(0x0101010101010101ull); | |
#ifdef WANT_VALGRIND_SUPPORT | |
extern int __valgrind; | |
#endif | |
size_t strlen(const char *s) | |
{ | |
const char *t = s; | |
word_t word; | |
word_t mask; | |
+#if __BYTE_ORDER != __LITTLE_ENDIAN | |
+ word_t orig_word; | |
+#endif | |
if (__unlikely(!s)) return 0; | |
#ifdef WANT_VALGRIND_SUPPORT | |
if (__unlikely(__valgrind)) { | |
register size_t i; | |
for (i=0; __likely(*s); ++s) ++i; | |
return i; | |
} | |
#endif | |
/* Byte compare up until word boundary */ | |
for (; ((unsigned long) t & (sizeof(magic)-1)); t++) | |
if (!*t) return t - s; | |
@@ -37,6 +52,9 @@ size_t strlen(const char *s) | |
/* Word compare */ | |
do { | |
word = *((word_t const *) t); t += sizeof word; | |
+#if __BYTE_ORDER != __LITTLE_ENDIAN | |
+ orig_word = word; | |
+#endif | |
word = (word - magic) &~ word; | |
word &= (magic << 7); | |
} while (__likely(word == 0)); | |
@@ -63,6 +81,18 @@ size_t strlen(const char *s) | |
default: { char exc[sizeof(word)==8]; (void)exc; } | |
} | |
#else | |
+ /* On big endian there's a corner case where the remaining up to | |
+ * (wordsize-1) bytes in a string are \001. In that case above code | |
+ * properly detects that a NUL byte is present in this word, but the | |
+ * result of the calculation in the loop will leave the following | |
+ * code thinking that _only_ NUL bytes are present in the remaining | |
+ * word, resulting in strlen returning a value that's too small. This | |
+ * is not a problem on little endian systems. */ | |
+ if (__unlikely(orig_word < magic)) { | |
+ for (t -= sizeof(word); __unlikely(*t); t++); | |
+ return t - s; | |
+ } | |
+ | |
mask = (magic << 7); | |
switch (sizeof(word)) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: Makefile | |
=================================================================== | |
RCS file: /cvs/dietlibc/Makefile,v | |
retrieving revision 1.211 | |
diff -u -p -r1.211 Makefile | |
--- Makefile 29 Mar 2016 15:56:32 -0000 1.211 | |
+++ Makefile 4 Apr 2016 20:53:59 -0000 | |
@@ -390,7 +390,8 @@ t1: | |
install-bin: $(OBJDIR)/start.o $(OBJDIR)/dietlibc.a $(OBJDIR)/librpc.a $(OBJDIR)/liblatin1.a $(OBJDIR)/libcompat.a $(OBJDIR)/elftrunc $(OBJDIR)/diet-i | |
$(INSTALL) -d $(DESTDIR)$(ILIBDIR) $(DESTDIR)$(MAN1DIR) $(DESTDIR)$(BINDIR) | |
- $(INSTALL) -m 644 $(OBJDIR)/start.o $(OBJDIR)/start-pie.o $(DESTDIR)$(ILIBDIR)/ | |
+ $(INSTALL) -m 644 $(OBJDIR)/start.o $(DESTDIR)$(ILIBDIR)/ | |
+ -$(INSTALL) -m 644 $(OBJDIR)/start-pie.o $(DESTDIR)$(ILIBDIR)/ | |
$(INSTALL) -m 644 $(OBJDIR)/libm.a $(OBJDIR)/libpthread.a $(OBJDIR)/librpc.a \ | |
$(OBJDIR)/liblatin1.a $(OBJDIR)/libcompat.a $(OBJDIR)/libcrypt.a $(DESTDIR)$(ILIBDIR) | |
$(INSTALL) -m 644 $(OBJDIR)/dietlibc.a $(DESTDIR)$(ILIBDIR)/libc.a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: Makefile | |
=================================================================== | |
RCS file: /cvs/dietlibc/Makefile,v | |
retrieving revision 1.211 | |
diff -u -p -r1.211 Makefile | |
--- Makefile 29 Mar 2016 15:56:32 -0000 1.211 | |
+++ Makefile 4 Apr 2016 20:55:00 -0000 | |
@@ -209,10 +209,10 @@ endif | |
CC+=-D__dietlibc__ | |
-$(OBJDIR)/start-pie.o: $(ARCH)/start.S | $(OBJDIR) | |
+$(OBJDIR)/start-pie.o: start.S | $(OBJDIR) | |
$(CCC) $(INC) $(CCFLAGS) $(EXTRACFLAGS) -c $< $(ASM_CFLAGS) -fpie -o $@ | |
-$(OBJDIR)/start.o: $(ARCH)/start.S | $(OBJDIR) | |
+$(OBJDIR)/start.o: start.S | $(OBJDIR) | |
$(CCC) $(INC) $(CCFLAGS) $(EXTRACFLAGS) -c $< $(ASM_CFLAGS) -fno-pie -o $@ | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: include/sys/ucontext.h | |
=================================================================== | |
RCS file: /cvs/dietlibc/include/sys/ucontext.h,v | |
retrieving revision 1.8 | |
diff -u -p -r1.8 ucontext.h | |
--- include/sys/ucontext.h 10 Oct 2014 14:54:30 -0000 1.8 | |
+++ include/sys/ucontext.h 4 Apr 2016 20:56:26 -0000 | |
@@ -87,8 +87,10 @@ typedef struct { | |
struct ucontext { | |
struct ucontext *uc_link; | |
unsigned long uc_flags; | |
- sigset_t uc_sigmask; | |
+ unsigned long __uc_sigmask; | |
mcontext_t uc_mcontext; | |
+ stack_t uc_stack; | |
+ sigset_t uc_sigmask; | |
}; | |
#elif defined(__s390__) | |
struct ucontext { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment