From fdf5f1b13123883ac1d5e298e5f32c7ed43578ce Mon Sep 17 00:00:00 2001 From: Bobby Bingham Date: Thu, 6 Feb 2014 22:11:22 -0600 Subject: 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. --- src/linux/clone.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/linux/clone.c (limited to 'src/linux') diff --git a/src/linux/clone.c b/src/linux/clone.c new file mode 100644 index 00000000..b9e55945 --- /dev/null +++ b/src/linux/clone.c @@ -0,0 +1,19 @@ +#include +#include +#include "pthread_impl.h" +#include "syscall.h" + +int clone(int (*func)(void *), void *stack, int flags, void *arg, ...) +{ + va_list ap; + pid_t *ptid, *ctid; + void *tls; + + va_start(ap, arg); + ptid = va_arg(ap, pid_t *); + tls = va_arg(ap, void *); + ctid = va_arg(ap, pid_t *); + va_end(ap); + + return __syscall_ret(__clone(func, stack, flags, arg, ptid, tls, ctid)); +} -- cgit v1.2.1