path: root/src/thread
diff options
authorBobby Bingham <>2014-02-06 22:11:22 -0600
committerBobby Bingham <>2014-02-09 20:07:43 -0600
commitfdf5f1b13123883ac1d5e298e5f32c7ed43578ce (patch)
tree56cddbaadf3f67c66a4914f4a3db7ae6d19a7aa6 /src/thread
parent7ee48f7b69523c68768684551bc37ba05496c27f (diff)
clone: make clone a wrapper around __clone
The architecture-specific assembly versions of clone did not set errno on failure, which is inconsistent with glibc. __clone still returns the error via its return value, and clone is now a wrapper that sets errno as needed. The public clone has also been moved to src/linux, as it's not directly related to the pthreads API. __clone is called by pthread_create, which does not report errors via errno. Though not strictly necessary, it's nice to avoid clobbering errno here.
Diffstat (limited to 'src/thread')
5 files changed, 3 insertions, 18 deletions
diff --git a/src/thread/arm/clone.s b/src/thread/arm/clone.s
index daf8f556..d146999b 100644
--- a/src/thread/arm/clone.s
+++ b/src/thread/arm/clone.s
@@ -1,10 +1,7 @@
.global __clone
-.weak clone
.type __clone,%function
-.type clone,%function
stmfd sp!,{r4,r5,r6,r7}
mov r7,#120
mov r6,r3
diff --git a/src/thread/clone.c b/src/thread/clone.c
index 339e28a3..be80c8ea 100644
--- a/src/thread/clone.c
+++ b/src/thread/clone.c
@@ -1,10 +1,7 @@
#include <errno.h>
-#include "libc.h"
+#include "pthread_impl.h"
int __clone(int (*func)(void *), void *stack, int flags, void *arg, ...)
- errno = ENOSYS;
- return -1;
+ return -ENOSYS;
-weak_alias(__clone, clone);
diff --git a/src/thread/i386/clone.s b/src/thread/i386/clone.s
index bebf01a3..52fe7efb 100644
--- a/src/thread/i386/clone.s
+++ b/src/thread/i386/clone.s
@@ -1,10 +1,7 @@
.global __clone
-.weak clone
.type __clone,@function
-.type clone,@function
push %ebp
mov %esp,%ebp
push %ebx
diff --git a/src/thread/microblaze/clone.s b/src/thread/microblaze/clone.s
index 030a9c31..13448a33 100644
--- a/src/thread/microblaze/clone.s
+++ b/src/thread/microblaze/clone.s
@@ -1,14 +1,11 @@
.global __clone
-.weak clone
.type __clone,@function
-.type clone,@function
# r5, r6, r7, r8, r9, r10, stack
# fn, st, fl, ar, pt, tl, ct
# fl, st, __, pt, ct, tl
andi r6, r6, -16
addi r6, r6, -16
swi r5, r6, 0
@@ -23,7 +20,7 @@ clone:
beqi r3, 1f
rtsd r15, 8
1: lwi r3, r1, 0
lwi r5, r1, 4
brald r15, r3
diff --git a/src/thread/x86_64/clone.s b/src/thread/x86_64/clone.s
index 4db081cd..ee59903a 100644
--- a/src/thread/x86_64/clone.s
+++ b/src/thread/x86_64/clone.s
@@ -1,10 +1,7 @@
.global __clone
-.weak clone
.type __clone,@function
-.type clone,@function
xor %eax,%eax
mov $56,%al
mov %rdi,%r11