fork.c 596 B

1234567891011121314151617181920212223242526272829
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * fork() for Xtensa uClibc
  4. *
  5. * Copyright (C) 2007 Tensilica Inc.
  6. *
  7. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  8. */
  9. /* Xtensa doesn't provide a 'fork' system call, so we use 'clone'. */
  10. #include <sys/syscall.h>
  11. #if defined __NR_clone && defined __ARCH_USE_MMU__
  12. # include <unistd.h>
  13. # include <signal.h>
  14. # include <cancel.h>
  15. pid_t fork(void)
  16. {
  17. return (pid_t) INLINE_SYSCALL(clone, 2, SIGCHLD, 0);
  18. }
  19. # ifdef __UCLIBC_HAS_THREADS__
  20. strong_alias(fork,__libc_fork)
  21. libc_hidden_weak(fork)
  22. # else
  23. libc_hidden_def(fork)
  24. # endif
  25. #endif