vfork.S 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. * Copyright (C) 2016-2017 Andes Technology, Inc.
  3. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  4. */
  5. /* Copyright (C) 2013 Free Software Foundation, Inc.
  6. The GNU C Library is free software; you can redistribute it and/or
  7. modify it under the terms of the GNU Lesser General Public
  8. License as published by the Free Software Foundation; either
  9. version 2.1 of the License, or (at your option) any later version.
  10. The GNU C Library is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. Lesser General Public License for more details.
  14. You should have received a copy of the GNU Lesser General Public
  15. License along with the GNU C Library; if not, see
  16. <http://www.gnu.org/licenses/>. */
  17. #include <tls.h>
  18. /* Save the PID value. */
  19. #define SAVE_PID \
  20. lwi $r1, [$r25 + PID_OFFSET];/* Get the thread pointer. */ \
  21. subri $r1, $r1, 0x0; /* Negate it. */ \
  22. bnez $r1, 1f; /* If it was zero... */ \
  23. sethi $r1, 0x80000; /* use 0x80000000 instead. */ \
  24. 1: swi $r1, [$r25 + PID_OFFSET];/* Store the temporary PID. */
  25. /* Restore the old PID value in the parent. */
  26. #define RESTORE_PID \
  27. beqz $r0, 1f; /* If we are the parent... */ \
  28. lwi $r1, [$r25 + PID_OFFSET];/* Get the thread pointer. */ \
  29. subri $r1, $r1, 0x0; /* Re-negate it. */ \
  30. sethi $r2, 0x80000; /* Load 0x80000000... */ \
  31. bne $r1, $r2, 2f; /* ... compare against it... */ \
  32. movi $r1, 0; /* ... use 0 instead. */ \
  33. 2: swi $r1, [$r25 + PID_OFFSET];/* Restore the PID. */ \
  34. 1:
  35. #include <../../../../../../../libc/sysdeps/linux/nds32/vfork.S>