sysdep.S 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /*
  2. * Copyright (C) 2016 Andes Technology, Inc.
  3. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  4. */
  5. /* Copyright (C) 1991-2003 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, write to the Free
  16. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  17. 02111-1307 USA. */
  18. #include <sysdep.h>
  19. #define _ERRNO_H
  20. #include <bits/errno.h>
  21. .text
  22. .globl __syscall_error
  23. ENTRY (__syscall_error)
  24. subri $r0, $r0, #0
  25. #define __syscall_error __syscall_error_1
  26. #undef syscall_error
  27. #ifdef NO_UNDERSCORES
  28. __syscall_error:
  29. #else
  30. syscall_error:
  31. #endif
  32. #ifdef PIC
  33. /* set GP register */
  34. pushm $gp, $lp
  35. cfi_adjust_cfa_offset(8)
  36. cfi_rel_offset(gp, 0)
  37. cfi_rel_offset(lp, 4)
  38. mfusr $r15, $PC
  39. sethi $gp, hi20(_GLOBAL_OFFSET_TABLE_+4)
  40. ori $gp, $gp, lo12(_GLOBAL_OFFSET_TABLE_+8)
  41. add $gp, $gp, $r15
  42. #endif
  43. #if defined (EWOULDBLOCK_sys) && EWOULDBLOCK_sys != EAGAIN
  44. /* We translate the system's EWOULDBLOCK error into EAGAIN.
  45. The GNU C library always defines EWOULDBLOCK==EAGAIN.
  46. EWOULDBLOCK_sys is the original number. */
  47. push $t0
  48. cfi_adjust_cfa_offset(4)
  49. li $t0, EWOULDBLOCK_sys
  50. bne $r0, $t0, 1f
  51. pop $t0
  52. cfi_adjust_cfa_offset(-4)
  53. li $r0, EAGAIN
  54. 1:
  55. #endif
  56. #ifdef _LIBC_REENTRANT
  57. push $lp
  58. cfi_adjust_cfa_offset(4)
  59. cfi_rel_offset(lp, 0)
  60. push $r0
  61. cfi_adjust_cfa_offset(4)
  62. cfi_rel_offset(r0, 0)
  63. #ifdef PIC
  64. bal C_SYMBOL_NAME(__errno_location@PLT)
  65. #else
  66. bal C_SYMBOL_NAME(__errno_location)
  67. #endif
  68. pop $r1
  69. cfi_adjust_cfa_offset(-4)
  70. cfi_restore(r1)
  71. swi $r1, [$r0]
  72. li $r0, -1
  73. pop $lp
  74. cfi_adjust_cfa_offset(-4)
  75. cfi_restore(lp)
  76. #ifdef PIC
  77. /* restore GP register */
  78. popm $gp, $lp
  79. cfi_adjust_cfa_offset(-8)
  80. cfi_restore(lp)
  81. cfi_restore(gp)
  82. #endif
  83. 2:
  84. ret
  85. #else
  86. #ifndef PIC
  87. l.w $r1, .L1
  88. swi $r0, [$r1]
  89. li $r0, -1
  90. ret
  91. .L1: .long C_SYMBOL_NAME(errno)
  92. #else
  93. s.w $r0, errno@GOTOFF
  94. li $r0, -1
  95. /* restore GP register */
  96. popm $gp, $lp
  97. cfi_adjust_cfa_offset(-8)
  98. cfi_restore(lp)
  99. cfi_restore(gp)
  100. 2:
  101. ret
  102. #endif
  103. #endif
  104. #undef __syscall_error
  105. END (__syscall_error)