sysdep.S 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /* Copyright (C) 1991,1992,1993,1994,1995,1996,1997,2000,2002,2004,2005
  2. Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, write to the Free
  14. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  15. 02111-1307 USA. */
  16. #include <sysdep.h>
  17. #define _ERRNO_H
  18. #include <bits/errno.h>
  19. #include <bp-asm.h>
  20. #include <bp-sym.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. cmpl $EWOULDBLOCK_sys, %eax /* 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. #ifndef PIC
  42. # if USE___THREAD
  43. # ifndef NO_TLS_DIRECT_SEG_REFS
  44. movl %eax, %gs:C_SYMBOL_NAME(errno@NTPOFF)
  45. # else
  46. movl %gs:0, %ecx
  47. movl %eax, C_SYMBOL_NAME(errno@NTPOFF)(%ecx)
  48. # endif
  49. # elif !defined _LIBC_REENTRANT
  50. movl %eax, C_SYMBOL_NAME(errno)
  51. # else
  52. pushl %eax
  53. PUSH_ERRNO_LOCATION_RETURN
  54. call BP_SYM (PAL(__errno_location))
  55. POP_ERRNO_LOCATION_RETURN
  56. popl %ecx
  57. movl %ecx, (%eax)
  58. # endif
  59. #else
  60. /* The caller has pushed %ebx and then set it up to
  61. point to the GOT before calling us through the PLT. */
  62. # if USE___THREAD
  63. movl C_SYMBOL_NAME(errno@GOTNTPOFF)(%ebx), %ecx
  64. /* Pop %ebx value saved before jumping here. */
  65. popl %ebx
  66. # ifndef NO_TLS_DIRECT_SEG_REFS
  67. addl %gs:0, %ecx
  68. movl %eax, (%ecx)
  69. # else
  70. movl %eax, %gs:0(%ecx)
  71. # endif
  72. # elif RTLD_PRIVATE_ERRNO
  73. movl %eax, C_SYMBOL_NAME(rtld_errno@GOTOFF)(%ebx)
  74. /* Pop %ebx value saved before jumping here. */
  75. popl %ebx
  76. # elif !defined _LIBC_REENTRANT
  77. movl C_SYMBOL_NAME(errno@GOT)(%ebx), %ecx
  78. /* Pop %ebx value saved before jumping here. */
  79. popl %ebx
  80. movl %eax, (%ecx)
  81. # else
  82. pushl %eax
  83. PUSH_ERRNO_LOCATION_RETURN
  84. call C_SYMBOL_NAME (BP_SYM (PAL(__errno_location))@PLT)
  85. POP_ERRNO_LOCATION_RETURN
  86. popl %ecx
  87. /* Pop %ebx value saved before jumping here. */
  88. popl %ebx
  89. movl %ecx, (%eax)
  90. # endif
  91. #endif
  92. movl $-1, %eax
  93. ret
  94. #undef __syscall_error
  95. END (__syscall_error)