[PATCH] fix test for vfork function
Mark Salter
msalter at redhat.com
Thu Apr 26 14:14:30 UTC 2012
A few places in the code check for existence of vfork by testing if
__NR_vfork is defined. Newer kernels don't have a vfork syscall in
which case, the library implements the vfork function using __NR_clone.
This patch adds a test for __UCLIBC_VFORK_USES_CLONE__ feature
definition which an architecture may define if vfork is implemented
using clone.
Signed-off-by: Mark Salter <msalter at redhat.com>
---
libc/stdio/popen.c | 2 +-
libc/stdlib/system.c | 2 +-
libc/stdlib/unix_grantpt.c | 2 +-
libc/sysdeps/linux/c6x/bits/uClibc_arch_features.h | 3 +++
4 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/libc/stdio/popen.c b/libc/stdio/popen.c
index d5c60cf..72ee60d 100644
--- a/libc/stdio/popen.c
+++ b/libc/stdio/popen.c
@@ -29,7 +29,7 @@
/* uClinux-2.0 has vfork, but Linux 2.0 doesn't */
#include <sys/syscall.h>
-#if ! defined __NR_vfork
+#if ! defined __NR_vfork && ! defined __UCLIBC_VFORK_USES_CLONE__
# define vfork fork
# define VFORK_LOCK ((void) 0)
# define VFORK_UNLOCK ((void) 0)
diff --git a/libc/stdlib/system.c b/libc/stdlib/system.c
index a92c307..cfea08e 100644
--- a/libc/stdlib/system.c
+++ b/libc/stdlib/system.c
@@ -26,7 +26,7 @@ extern __typeof(system) __libc_system;
#if !defined __UCLIBC_HAS_THREADS_NATIVE__ || defined __sparc__
/* uClinux-2.0 has vfork, but Linux 2.0 doesn't */
#include <sys/syscall.h>
-#ifndef __NR_vfork
+#if !defined __NR_vfork && !defined __UCLIBC_VFORK_USES_CLONE__
# define vfork fork
#endif
diff --git a/libc/stdlib/unix_grantpt.c b/libc/stdlib/unix_grantpt.c
index 1be0a7d..cba7fc9 100644
--- a/libc/stdlib/unix_grantpt.c
+++ b/libc/stdlib/unix_grantpt.c
@@ -33,7 +33,7 @@
/* uClinux-2.0 has vfork, but Linux 2.0 doesn't */
#include <sys/syscall.h>
-#if ! defined __NR_vfork
+#if ! defined(__NR_vfork) && ! defined(__NR_clone)
#define vfork fork
#endif
diff --git a/libc/sysdeps/linux/c6x/bits/uClibc_arch_features.h b/libc/sysdeps/linux/c6x/bits/uClibc_arch_features.h
index 59e7de9..936748a 100644
--- a/libc/sysdeps/linux/c6x/bits/uClibc_arch_features.h
+++ b/libc/sysdeps/linux/c6x/bits/uClibc_arch_features.h
@@ -45,4 +45,7 @@
/* only weird assemblers generally need this */
#define __UCLIBC_ASM_LINE_SEP__ @
+/* define if vfork function exists */
+#define __UCLIBC_VFORK_USES_CLONE__
+
#endif /* _BITS_UCLIBC_ARCH_FEATURES_H */
--
1.7.9.1
More information about the uClibc
mailing list