_exit.c 939 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. * exit syscall for uClibc
  3. *
  4. * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
  5. *
  6. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  7. */
  8. #include <unistd.h>
  9. #include <stdlib.h>
  10. #include <sys/syscall.h>
  11. #include <bits/kernel-features.h>
  12. #ifdef __UCLIBC_ABORT_INSTRUCTION__
  13. # define ABORT_INSTRUCTION __asm__(__UCLIBC_ABORT_INSTRUCTION__)
  14. #else
  15. # warning "no abort instruction defined for this arch"
  16. #endif
  17. /* have to check for kernel 2.5.35 too, since NR was earlier present */
  18. #if defined __NR_exit_group && __LINUX_KERNEL_VERSION >= 0x020600 \
  19. && defined __UCLIBC_HAS_THREADS__
  20. # undef __NR_exit
  21. # define __NR_exit __NR_exit_group
  22. #endif
  23. void _exit(int status)
  24. {
  25. /* The loop is added only to keep gcc happy. */
  26. while(1)
  27. {
  28. INLINE_SYSCALL(exit, 1, status);
  29. #ifdef ABORT_INSTRUCTION
  30. ABORT_INSTRUCTION;
  31. #endif
  32. }
  33. }
  34. libc_hidden_def(_exit)
  35. #ifdef __USE_ISOC99
  36. weak_alias(_exit,_Exit)
  37. #endif