vfork.S 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * This file is subject to the terms and conditions of the LGPL V2.1
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (C) 2018 Kalray Inc.
  7. */
  8. #include <sys/syscall.h>
  9. #include <sysdep.h>
  10. /* We do not want COMPAT to be enabled in our kernel, hence vfork
  11. * is not available. Use clone to do the same job with appropriate flags */
  12. #define _SIGNAL_H
  13. #include <bits/signum.h> /* For SIGCHLD */
  14. #define CLONE_VM 0x00000100
  15. #define CLONE_VFORK 0x00004000
  16. #define CLONE_FLAGS_FOR_VFORK (CLONE_VM|CLONE_VFORK|SIGCHLD)
  17. ENTRY(__vfork)
  18. make $r0 = CLONE_FLAGS_FOR_VFORK
  19. /* Not sure if needed to zero-out other parameters but better
  20. * be safe than sorry */
  21. make $r1 = 0
  22. make $r2 = 0
  23. ;;
  24. make $r3 = 0
  25. make $r4 = 0
  26. ;;
  27. scall SYS_ify(clone)
  28. ;;
  29. /* If PID < 0 then it's an error, else, simply return */
  30. cb.dltz $r0 ? err
  31. ;;
  32. ret
  33. ;;
  34. L(err):
  35. goto __syscall_error
  36. ;;
  37. /* Never return */
  38. errop
  39. ;;
  40. END(__vfork)
  41. weak_alias(__vfork,vfork)
  42. libc_hidden_def(vfork)