diff options
author | Rob Landley <rob@landley.net> | 2014-12-04 21:46:59 -0600 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2014-12-04 21:46:59 -0600 |
commit | 50fc9ed007b084883fb09c64866c45c571e70a99 (patch) | |
tree | e74fcf5c070a01666382e077394f62687af69dd1 /lib | |
parent | 2fb85a3588bf2271e0506c5ab3bcb6a84bf77255 (diff) | |
download | toybox-50fc9ed007b084883fb09c64866c45c571e70a99.tar.gz toybox-50fc9ed007b084883fb09c64866c45c571e70a99.tar.bz2 toybox-50fc9ed007b084883fb09c64866c45c571e70a99.zip |
Work with buildroot's extensively patched uClibc, and for nommu support move xfork() to portability.h and #ifdef based on __uClinux__ (which seems to be the nommu compiler define).
Diffstat (limited to 'lib')
-rw-r--r-- | lib/lib.h | 1 | ||||
-rw-r--r-- | lib/portability.c | 11 | ||||
-rw-r--r-- | lib/portability.h | 21 | ||||
-rw-r--r-- | lib/xwrap.c | 9 |
4 files changed, 32 insertions, 10 deletions
@@ -93,7 +93,6 @@ void xprintf(char *format, ...); void xputs(char *s); void xputc(char c); void xflush(void); -pid_t xfork(void); void xexec_optargs(int skip); void xexec(char **argv); pid_t xpopen_both(char **argv, int *pipes); diff --git a/lib/portability.c b/lib/portability.c index 910b1ea..7d6d85f 100644 --- a/lib/portability.c +++ b/lib/portability.c @@ -6,6 +6,17 @@ #include "toys.h" +#if !defined(__uClinux__) +pid_t xfork(void) +{ + pid_t pid = fork(); + + if (pid < 0) perror_exit("fork"); + + return pid; +} +#endif + #if defined(__APPLE__) ssize_t getdelim(char **linep, size_t *np, int delim, FILE *stream) { diff --git a/lib/portability.h b/lib/portability.h index d58e592..1464c65 100644 --- a/lib/portability.h +++ b/lib/portability.h @@ -72,13 +72,28 @@ pid_t getsid(pid_t pid); // any flag newer than MS_MOVE, which was added in 2001 (linux 2.5.0.5), // eleven years earlier. +#include <sys/mount.h> +#ifndef MS_MOVE #define MS_MOVE (1<<13) +#endif +#ifndef MS_REC #define MS_REC (1<<14) +#endif +#ifndef MS_SILENT #define MS_SILENT (1<<15) +#endif +#ifndef MS_UNBINDABLE #define MS_UNBINDABLE (1<<17) +#endif +#ifndef MS_PRIVATE #define MS_PRIVATE (1<<18) +#endif +#ifndef MS_SLAVE #define MS_SLAVE (1<<19) +#endif +#ifndef MS_SHARED #define MS_SHARED (1<<20) +#endif // When building under obsolete glibc (Ubuntu 8.04-ish), hold its hand a bit. #elif __GLIBC__ == 2 && __GLIBC_MINOR__ < 10 @@ -206,3 +221,9 @@ typedef double FLOAT; typedef float FLOAT; #endif +#ifndef __uClinux__ +pid_t xfork(void); +#endif + +//#define strncpy(...) @@strncpyisbadmmkay@@ +//#define strncat(...) @@strcatisbadmmkay@@ diff --git a/lib/xwrap.c b/lib/xwrap.c index 96db352..d703065 100644 --- a/lib/xwrap.c +++ b/lib/xwrap.c @@ -127,15 +127,6 @@ void xflush(void) if (fflush(stdout) || ferror(stdout)) perror_exit("write");; } -pid_t xfork(void) -{ - pid_t pid = fork(); - - if (pid < 0) perror_exit("fork"); - - return pid; -} - // Call xexec with a chunk of optargs, starting at skip. (You can't just // call xexec() directly because toy_init() frees optargs.) void xexec_optargs(int skip) |