vfork.c 504 B

12345678910111213141516171819202122232425
  1. /* orginally from include/unistd.h, written by ndf@linux.mit.edu> */
  2. #include <unistd.h>
  3. #include <sys/types.h>
  4. #include <asm/unistd.h>
  5. #ifndef __NR_vfork
  6. #define __NR_vfork __NR_fork /* uClinux-2.0 only has fork which is vfork */
  7. #endif
  8. pid_t vfork(void)
  9. {
  10. pid_t __res;
  11. __asm__ __volatile__ ("movel %1,%%d0;"
  12. "trap #0;"
  13. "movel %%d0,%0"
  14. : "=d" (__res)
  15. : "0" (__NR_vfork)
  16. : "%d0");
  17. if (__res >= (unsigned long)-4096) {
  18. errno = -__res;
  19. __res = (pid_t)-1;
  20. }
  21. return(__res);
  22. }