diff options
author | David Schleef <ds@schleef.org> | 2001-11-26 09:19:30 +0000 |
---|---|---|
committer | David Schleef <ds@schleef.org> | 2001-11-26 09:19:30 +0000 |
commit | e4cfe3fb823dc44c0e3e884e53d1ae7c05ae7416 (patch) | |
tree | 7ce9d1c188f48f13d57df2be1a681ce1b4e08204 /libc/sysdeps/linux/powerpc/vfork.c | |
parent | b76b3fcd18d8c7e0ed25cccc355f6f0192c1e83b (diff) |
Rewrite vfork() as C, should now work. Changed longjmp.S and setjmp.S
to use GCC's internal ppc-asm.h, and added macro to disable FP save/
restore in longjmp and setjmp. Fixed name of _setjmp() (was __setjmp).
Fixed _setjmp to be PIC.
Diffstat (limited to 'libc/sysdeps/linux/powerpc/vfork.c')
-rw-r--r-- | libc/sysdeps/linux/powerpc/vfork.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/libc/sysdeps/linux/powerpc/vfork.c b/libc/sysdeps/linux/powerpc/vfork.c new file mode 100644 index 000000000..fcf020804 --- /dev/null +++ b/libc/sysdeps/linux/powerpc/vfork.c @@ -0,0 +1,38 @@ + +#include <unistd.h> +#include <sys/syscall.h> +#include <sys/types.h> +#include <errno.h> + + +int vfork(void) +{ + unsigned long __sc_ret, __sc_err; + register unsigned long __sc_0 __asm__ ("r0"); + register unsigned long __sc_3 __asm__ ("r3"); + + __sc_0 = __NR_vfork; + __asm__ __volatile__ + ("sc \n\t" + "mfcr %1 " + : "=&r" (__sc_3), "=&r" (__sc_0) + : "0" (__sc_3), "1" (__sc_0) + : __syscall_clobbers); + __sc_ret = __sc_3; + __sc_err = __sc_0; + + if((__sc_err & 0x10000000) && (__sc_ret == ENOSYS)){ + __sc_0 = __NR_fork; + __asm__ __volatile__ + ("sc \n\t" + "mfcr %1 " + : "=&r" (__sc_3), "=&r" (__sc_0) + : "0" (__sc_3), "1" (__sc_0) + : __syscall_clobbers); + __sc_ret = __sc_3; + __sc_err = __sc_0; + } + + __syscall_return (pid_t); +} + |