sysdep.S 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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 C_SYMBOL_NAME(errno)
  23. .globl __syscall_error
  24. ENTRY (__syscall_error)
  25. #ifdef OLD_ABI
  26. subri $r5, $r5, #0
  27. #else
  28. subri $r0, $r0, #0
  29. #endif
  30. #define __syscall_error __syscall_error_1
  31. #undef syscall_error
  32. #ifdef NO_UNDERSCORES
  33. __syscall_error:
  34. #else
  35. syscall_error:
  36. #endif
  37. #ifdef PIC
  38. /* set GP register */
  39. pushm $gp, $lp
  40. #ifdef __NDS32_N1213_43U1H__
  41. jal 2f
  42. sethi $gp, hi20(_GLOBAL_OFFSET_TABLE_)
  43. ori $gp, $gp, lo12(_GLOBAL_OFFSET_TABLE_+4)
  44. add $gp, $gp, $lp
  45. #else
  46. mfusr $r15, $PC
  47. sethi $gp, hi20(_GLOBAL_OFFSET_TABLE_+4)
  48. ori $gp, $gp, lo12(_GLOBAL_OFFSET_TABLE_+8)
  49. add $gp, $gp, $r15
  50. #endif
  51. #endif
  52. #if defined (EWOULDBLOCK_sys) && EWOULDBLOCK_sys != EAGAIN
  53. /* We translate the system's EWOULDBLOCK error into EAGAIN.
  54. The GNU C library always defines EWOULDBLOCK==EAGAIN.
  55. EWOULDBLOCK_sys is the original number. */
  56. push $t0
  57. li $t0, EWOULDBLOCK_sys
  58. bne $r0, $t0, 1f
  59. pop $t0
  60. li $r0, EAGAIN
  61. 1:
  62. #endif
  63. #ifdef _LIBC_REENTRANT
  64. push $lp
  65. push $r0
  66. #if defined(NDS32_ABI_2) || defined(NDS32_ABI_2FP)
  67. #else
  68. addi $sp, $sp, -24
  69. #endif
  70. #ifdef PIC
  71. bal C_SYMBOL_NAME(__errno_location@PLT)
  72. #else
  73. bal C_SYMBOL_NAME(__errno_location)
  74. #endif
  75. #if defined(NDS32_ABI_2) || defined(NDS32_ABI_2FP)
  76. #else
  77. addi $sp, $sp, 24
  78. #endif
  79. pop $r1
  80. swi $r1, [$r0]
  81. li $r0, -1
  82. pop $lp
  83. #ifdef PIC
  84. /* restore GP register */
  85. popm $gp, $lp
  86. #endif
  87. 2:
  88. ret
  89. #else
  90. #ifndef PIC
  91. l.w $r1, .L1
  92. swi $r0, [$r1]
  93. li $r0, -1
  94. ret
  95. .L1: .long C_SYMBOL_NAME(errno)
  96. #else
  97. s.w $r0, errno@GOTOFF
  98. li $r0, -1
  99. /* restore GP register */
  100. popm $gp, $lp
  101. 2:
  102. ret
  103. #endif
  104. #endif
  105. #undef __syscall_error
  106. END (__syscall_error)