summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAustin Foxley <austinf@cetoncorp.com>2009-12-19 14:02:14 -0800
committerAustin Foxley <austinf@cetoncorp.com>2009-12-19 14:03:00 -0800
commit875d11eec5df38bae0003df4a884ef962cf28590 (patch)
tree83667b7ab2470a3aba40fb9ee868784d77d7e900
parentf3217f9be3225c4943677d03b274cbc0cb4ed228 (diff)
parent23528282b771d1af3df0fa17f1e909ad3b663f59 (diff)
Merge commit 'origin/master' into nptl
Conflicts: libc/signal/sigpause.c libc/string/x86_64/memset.S Signed-off-by: Austin Foxley <austinf@cetoncorp.com>
-rw-r--r--libc/stdlib/malloc/free.c6
-rw-r--r--libc/stdlib/malloc/malloc.c7
-rw-r--r--libc/string/x86_64/bzero.S1
-rw-r--r--libc/string/x86_64/memcpy.S2
-rw-r--r--libc/string/x86_64/mempcpy.S1
-rw-r--r--libc/string/x86_64/memset.S4
-rw-r--r--libc/sysdeps/linux/common/ssp.c3
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h2
8 files changed, 16 insertions, 10 deletions
diff --git a/libc/stdlib/malloc/free.c b/libc/stdlib/malloc/free.c
index c17e7ec2a..e7b6a290a 100644
--- a/libc/stdlib/malloc/free.c
+++ b/libc/stdlib/malloc/free.c
@@ -177,14 +177,14 @@ __free_to_heap (void *mem, struct heap_free_area **heap
/* Start searching again from the end of this block. */
start = mmb_end;
+ /* Release the descriptor block we used. */
+ free_to_heap (mmb, &__malloc_mmb_heap, &__malloc_mmb_heap_lock);
+
/* We have to unlock the heap before we recurse to free the mmb
descriptor, because we might be unmapping from the mmb
heap. */
__heap_unlock (heap_lock);
- /* Release the descriptor block we used. */
- free_to_heap (mmb, &__malloc_mmb_heap, &__malloc_mmb_heap_lock);
-
/* Do the actual munmap. */
munmap ((void *)mmb_start, mmb_end - mmb_start);
diff --git a/libc/stdlib/malloc/malloc.c b/libc/stdlib/malloc/malloc.c
index 337206f09..d58a7d0ee 100644
--- a/libc/stdlib/malloc/malloc.c
+++ b/libc/stdlib/malloc/malloc.c
@@ -46,7 +46,7 @@ struct malloc_mmb *__malloc_mmapped_blocks = 0;
HEAP_DECLARE_STATIC_FREE_AREA (initial_mmb_fa, 48); /* enough for 3 mmbs */
struct heap_free_area *__malloc_mmb_heap = HEAP_INIT_WITH_FA (initial_mmb_fa);
#ifdef HEAP_USE_LOCKING
-malloc_mutex_t __malloc_mmb_heap_lock = PTHREAD_MUTEX_INITIALIZER;
+malloc_mutex_t __malloc_mmb_heap_lock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
#endif
#endif /* __UCLIBC_UCLINUX_BROKEN_MUNMAP__ */
@@ -149,19 +149,19 @@ __malloc_from_heap (size_t size, struct heap_free_area **heap
/* Try again to allocate. */
mem = __heap_alloc (heap, &size);
- __heap_unlock (heap_lock);
#if !defined(MALLOC_USE_SBRK) && defined(__UCLIBC_UCLINUX_BROKEN_MUNMAP__)
/* Insert a record of BLOCK in sorted order into the
__malloc_mmapped_blocks list. */
+ new_mmb = malloc_from_heap (sizeof *new_mmb, &__malloc_mmb_heap, &__malloc_mmb_heap_lock);
+
for (prev_mmb = 0, mmb = __malloc_mmapped_blocks;
mmb;
prev_mmb = mmb, mmb = mmb->next)
if (block < mmb->mem)
break;
- new_mmb = malloc_from_heap (sizeof *new_mmb, &__malloc_mmb_heap, &__malloc_mmb_heap_lock);
new_mmb->next = mmb;
new_mmb->mem = block;
new_mmb->size = block_size;
@@ -175,6 +175,7 @@ __malloc_from_heap (size_t size, struct heap_free_area **heap
(unsigned)new_mmb,
(unsigned)new_mmb->mem, block_size);
#endif /* !MALLOC_USE_SBRK && __UCLIBC_UCLINUX_BROKEN_MUNMAP__ */
+ __heap_unlock (heap_lock);
}
}
diff --git a/libc/string/x86_64/bzero.S b/libc/string/x86_64/bzero.S
index 4d179ec4e..231d7cb41 100644
--- a/libc/string/x86_64/bzero.S
+++ b/libc/string/x86_64/bzero.S
@@ -1,5 +1,6 @@
#include <features.h>
#ifdef __UCLIBC_SUSV3_LEGACY__
# define memset bzero
+# define __memset_chk __bzero_chk
# include "memset.S"
#endif
diff --git a/libc/string/x86_64/memcpy.S b/libc/string/x86_64/memcpy.S
index 011291447..6d941e0f2 100644
--- a/libc/string/x86_64/memcpy.S
+++ b/libc/string/x86_64/memcpy.S
@@ -29,7 +29,9 @@
#if defined __PIC__ && !defined NOT_IN_libc
ENTRY (__memcpy_chk)
cmpq %rdx, %rcx
+#if defined __UCLIBC_HAS_SSP__
jb HIDDEN_JUMPTARGET (__chk_fail)
+#endif
END (__memcpy_chk)
#endif
ENTRY (BP_SYM (memcpy))
diff --git a/libc/string/x86_64/mempcpy.S b/libc/string/x86_64/mempcpy.S
index 3816d9f72..b0607aa57 100644
--- a/libc/string/x86_64/mempcpy.S
+++ b/libc/string/x86_64/mempcpy.S
@@ -1,3 +1,4 @@
#define memcpy mempcpy
+#define __memcpy_chk __mempcpy_chk
#include "memcpy.S"
libc_hidden_def(mempcpy)
diff --git a/libc/string/x86_64/memset.S b/libc/string/x86_64/memset.S
index 562574a4d..df265f394 100644
--- a/libc/string/x86_64/memset.S
+++ b/libc/string/x86_64/memset.S
@@ -29,10 +29,12 @@
#define LARGE $120000
.text
-#if !BZERO_P && defined __PIC__ && !defined NOT_IN_libc
+#if defined __PIC__ && !defined NOT_IN_libc
ENTRY (__memset_chk)
cmpq %rdx, %rcx
+#if defined __UCLIBC_HAS_SSP__
jb HIDDEN_JUMPTARGET (__chk_fail)
+#endif
END (__memset_chk)
#endif
ENTRY (memset)
diff --git a/libc/sysdeps/linux/common/ssp.c b/libc/sysdeps/linux/common/ssp.c
index 69611cab5..a2d7ff2ca 100644
--- a/libc/sysdeps/linux/common/ssp.c
+++ b/libc/sysdeps/linux/common/ssp.c
@@ -100,7 +100,6 @@ void __stack_chk_fail(void)
terminate();
}
-#if 0
void __chk_fail(void) attribute_noreturn;
void __chk_fail(void)
{
@@ -115,4 +114,4 @@ void __chk_fail(void)
while(1)
terminate();
}
-#endif
+
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h
index de3609e9d..5d686299c 100644
--- a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h
@@ -130,7 +130,7 @@ __LABEL($syscall_error) \
extern int __local_multiple_threads attribute_hidden;
# define SINGLE_THREAD_P \
__builtin_expect (__local_multiple_threads == 0, 1)
-# elif defined(PIC)
+# elif defined(__PIC__)
# define SINGLE_THREAD_P(reg) ldl reg, __local_multiple_threads(gp) !gprel
# else
# define SINGLE_THREAD_P(reg) \