_exit.c 964 B

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