[git commit 0_9_30] daemon: fix up INTERNAL_SYSCALL() usage

Mike Frysinger vapier at gentoo.org
Thu Dec 17 12:42:26 UTC 2009


commit: http://git.uclibc.org/uClibc/commit/?id=38dcba96af08c05f91608017fda1b5f54b0307c3
branch: http://git.uclibc.org/uClibc/commit/?id=refs/heads/0_9_30

Make sure we declare the error properly in case a port uses it, and fix the
invocation of exit().  Since clone() will be returning a pid, assume that
the value will not have the MSB set (negative) to simplify the error test a
bit more.  If gcc supports it, force this function to always be heavily
optimized in a bid to avoid stack usage as much as possible.

Signed-off-by: James Coleman <james.coleman at ubicom.com>
Signed-off-by: Mike Frysinger <vapier at gentoo.org>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop at gmail.com>
---
 libc/unistd/daemon.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/libc/unistd/daemon.c b/libc/unistd/daemon.c
index 240b489..6f414ae 100644
--- a/libc/unistd/daemon.c
+++ b/libc/unistd/daemon.c
@@ -63,12 +63,14 @@ libc_hidden_proto(fork)
 /* use clone() to get fork() like behavior here -- we just want to disassociate
  * from the controlling terminal
  */
-static inline pid_t _fork_parent(void)
+static inline attribute_optimize("O3")
+pid_t _fork_parent(void)
 {
-	register unsigned long ret = INTERNAL_SYSCALL(clone, wtf, 2, CLONE_VM, 0);
-	if (ret != -1 && ret != 0)
+	INTERNAL_SYSCALL_DECL(err);
+	register long ret = INTERNAL_SYSCALL(clone, err, 2, CLONE_VM, 0);
+	if (ret > 0)
 		/* parent needs to die now w/out touching stack */
-		INTERNAL_SYSCALL(exit, wtf, 0);
+		INTERNAL_SYSCALL(exit, err, 1, 0);
 	return ret;
 }
 static inline pid_t fork_parent(void)
-- 
1.6.3.3



More information about the uClibc-cvs mailing list