sysdep.S 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /* Copyright (C) 2001, 2002, 2004, 2005 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. The GNU C Library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public
  5. License as published by the Free Software Foundation; either
  6. version 2.1 of the License, or (at your option) any later version.
  7. The GNU C Library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public
  12. License along with the GNU C Library; if not, write to the Free
  13. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  14. 02111-1307 USA. */
  15. #include <sysdep.h>
  16. #define _ERRNO_H
  17. #include <bits/errno.h>
  18. #include <bp-asm.h>
  19. #include <bp-sym.h>
  20. //#include <tls.h>
  21. #ifdef IS_IN_rtld
  22. # include <dl-sysdep.h> /* Defines RTLD_PRIVATE_ERRNO. */
  23. #endif
  24. .globl C_SYMBOL_NAME(errno)
  25. .globl syscall_error
  26. #undef syscall_error
  27. #ifdef NO_UNDERSCORES
  28. __syscall_error:
  29. #else
  30. syscall_error:
  31. #endif
  32. #if defined (EWOULDBLOCK_sys) && EWOULDBLOCK_sys != EAGAIN
  33. /* We translate the system's EWOULDBLOCK error into EAGAIN.
  34. The GNU C library always defines EWOULDBLOCK==EAGAIN.
  35. EWOULDBLOCK_sys is the original number. */
  36. cmpq $EWOULDBLOCK_sys, %rax /* Is it the old EWOULDBLOCK? */
  37. jne notb /* Branch if not. */
  38. movl $EAGAIN, %eax /* Yes; translate it to EAGAIN. */
  39. notb:
  40. #endif
  41. #if USE___THREAD
  42. # ifdef PIC
  43. movq C_SYMBOL_NAME(errno@GOTTPOFF)(%rip), %rcx
  44. movl %eax, %fs:0(%rcx)
  45. # else
  46. movl %eax, %fs:C_SYMBOL_NAME(errno@TPOFF)
  47. # endif
  48. #elif !defined PIC
  49. # ifndef _LIBC_REENTRANT
  50. movl %eax, C_SYMBOL_NAME(errno)
  51. # else
  52. pushq %rax
  53. cfi_adjust_cfa_offset(8)
  54. PUSH_ERRNO_LOCATION_RETURN
  55. call BP_SYM (PAL(__errno_location))
  56. POP_ERRNO_LOCATION_RETURN
  57. popq %rcx
  58. cfi_adjust_cfa_offset(-8)
  59. movl %ecx, (%rax)
  60. # endif
  61. #else
  62. # if RTLD_PRIVATE_ERRNO
  63. leaq rtld_errno(%rip), %rcx
  64. movl %eax, (%rcx)
  65. # elif !defined _LIBC_REENTRANT
  66. movq C_SYMBOL_NAME(errno)@GOTPCREL(%rip), %rcx
  67. movl %eax, (%rcx)
  68. # else
  69. pushq %rax
  70. cfi_adjust_cfa_offset(8)
  71. PUSH_ERRNO_LOCATION_RETURN
  72. call C_SYMBOL_NAME (BP_SYM (PAL(__errno_location))@PLT)
  73. POP_ERRNO_LOCATION_RETURN
  74. popq %rcx
  75. cfi_adjust_cfa_offset(-8)
  76. movl %ecx, (%rax)
  77. # endif
  78. #endif
  79. movq $-1, %rax
  80. ret
  81. #undef __syscall_error
  82. END (__syscall_error)