svn commit: [26006] branches/uClibc-nptl: extra/scripts include libc/unistd

kraj at uclibc.org kraj at uclibc.org
Tue Apr 7 06:23:18 UTC 2009


Author: kraj
Date: 2009-04-07 06:23:17 +0000 (Tue, 07 Apr 2009)
New Revision: 26006

Log:
Merged revisions 25971,26002 via svnmerge from 
svn+ssh://svn.uclibc.org/svn/trunk/uClibc

........
  r25971 | vapier | 2009-04-05 23:40:57 -0700 (Sun, 05 Apr 2009) | 1 line
  
  apply getline() fix from linux kernel
........
  r26002 | vapier | 2009-04-06 22:52:48 -0700 (Mon, 06 Apr 2009) | 1 line
  
  implement daemon() using clone() on no-mmu systems as suggested by Jamie Lokier
........


Modified:
   branches/uClibc-nptl/
   branches/uClibc-nptl/extra/scripts/unifdef.c
   branches/uClibc-nptl/include/unistd.h
   branches/uClibc-nptl/libc/unistd/Makefile.in
   branches/uClibc-nptl/libc/unistd/daemon.c


Changeset:

Property changes on: branches/uClibc-nptl
___________________________________________________________________
Modified: svnmerge-integrated
   - /trunk/uClibc:1-25846

   + /trunk/uClibc:1-26005

Modified: branches/uClibc-nptl/extra/scripts/unifdef.c
===================================================================
--- branches/uClibc-nptl/extra/scripts/unifdef.c	2009-04-07 06:08:14 UTC (rev 26005)
+++ branches/uClibc-nptl/extra/scripts/unifdef.c	2009-04-07 06:23:17 UTC (rev 26006)
@@ -206,7 +206,7 @@
 static void             error(const char *);
 static int              findsym(const char *);
 static void             flushline(bool);
-static Linetype         getline(void);
+static Linetype         get_line(void);
 static Linetype         ifeval(const char **);
 static void             ignoreoff(void);
 static void             ignoreon(void);
@@ -517,7 +517,7 @@
 
 	for (;;) {
 		linenum++;
-		lineval = getline();
+		lineval = get_line();
 		trans_table[ifstate[depth]][lineval]();
 		debug("process %s -> %s depth %d",
 		    linetype_name[lineval],
@@ -531,7 +531,7 @@
  * help from skipcomment().
  */
 static Linetype
-getline(void)
+get_line(void)
 {
 	const char *cp;
 	int cursym;
@@ -889,9 +889,8 @@
 				cp += 1;
 			} else if (strchr(" \t", *cp) != NULL) {
 				cp += 1;
-			} else {
+			} else
 				return (cp);
-			}
 			continue;
 		case CXX_COMMENT:
 			if (strncmp(cp, "\n", 1) == 0) {

Modified: branches/uClibc-nptl/include/unistd.h
===================================================================
--- branches/uClibc-nptl/include/unistd.h	2009-04-07 06:08:14 UTC (rev 26005)
+++ branches/uClibc-nptl/include/unistd.h	2009-04-07 06:23:17 UTC (rev 26006)
@@ -956,12 +956,10 @@
 extern void setusershell (void) __THROW; /* Rewind and re-read the file.  */
 
 
-#ifdef __ARCH_USE_MMU__
 /* Put the program in the background, and dissociate from the controlling
    terminal.  If NOCHDIR is zero, do `chdir ("/")'.  If NOCLOSE is zero,
    redirects stdin, stdout, and stderr to /dev/null.  */
 extern int daemon (int __nochdir, int __noclose) __THROW __wur;
-#endif
 #endif /* Use BSD || X/Open.  */
 
 

Modified: branches/uClibc-nptl/libc/unistd/Makefile.in
===================================================================
--- branches/uClibc-nptl/libc/unistd/Makefile.in	2009-04-07 06:08:14 UTC (rev 26005)
+++ branches/uClibc-nptl/libc/unistd/Makefile.in	2009-04-07 06:23:17 UTC (rev 26006)
@@ -14,8 +14,6 @@
 
 ifeq ($(ARCH_USE_MMU),y)
 CSRC := $(filter-out __exec_alloc.c,$(CSRC))
-else
-CSRC := $(filter-out daemon.c,$(CSRC))
 endif
 
 ifeq ($(UCLIBC_HAS_GNU_GETOPT),y)

Modified: branches/uClibc-nptl/libc/unistd/daemon.c
===================================================================
--- branches/uClibc-nptl/libc/unistd/daemon.c	2009-04-07 06:08:14 UTC (rev 26005)
+++ branches/uClibc-nptl/libc/unistd/daemon.c	2009-04-07 06:23:17 UTC (rev 26006)
@@ -61,18 +61,36 @@
 /* libc_hidden_proto(chdir) */
 /* libc_hidden_proto(fork) */
 
+#ifndef __ARCH_USE_MMU__
+#include <sys/syscall.h>
+/* use clone() to get fork() like behavior here -- we just want to disassociate
+ * from the controlling terminal
+ */
+static inline pid_t fork_parent(void)
+{
+	register unsigned long ret = INTERNAL_SYSCALL(clone, wtf, 2, CLONE_VM, 0);
+	if (ret != -1 && ret != 0)
+		/* parent needs to die now w/out touching stack */
+		INTERNAL_SYSCALL(exit, wtf, 0);
+	return ret;
+}
+#else
+static inline pid_t fork_parent(void)
+{
+	switch (fork()) {
+		case -1: return -1;
+		case 0:  return 0;
+		default: _exit(0);
+	}
+}
+#endif
+
 int daemon( int nochdir, int noclose )
 {
 	int fd;
 
-	switch (fork()) {
-		case -1:
-			return(-1);
-		case 0:
-			break;
-		default:
-			_exit(0);
-	}
+	if (fork_parent() == -1)
+		return -1;
 
 	if (setsid() == -1)
 		return(-1);



More information about the uClibc-cvs mailing list