sysdep.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /* Copyright (C) 2000-2016 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 License as
  5. published by the Free Software Foundation; either version 2.1 of the
  6. 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, see
  13. <http://www.gnu.org/licenses/>. */
  14. #include <common/sysdep.h>
  15. #ifdef __ASSEMBLER__
  16. # define ALIGNARG(log2) log2
  17. # define ASM_SIZE_DIRECTIVE(name) .size name,.-name
  18. /* Define an entry point visible from C. */
  19. # define ENTRY(name) \
  20. .globl C_SYMBOL_NAME(name); \
  21. .type C_SYMBOL_NAME(name),@function; \
  22. .align ALIGNARG(2); \
  23. C_LABEL(name)
  24. # undef END
  25. # define END(name) ASM_SIZE_DIRECTIVE(name)
  26. /* Local label name for asm code. */
  27. # ifndef L
  28. # define L(name) $L##name
  29. # endif
  30. /* We don't want the label for the error handler to be visible in the symbol
  31. table when we define it here. */
  32. # ifdef __PIC__
  33. # define SYSCALL_ERROR_LABEL 0f
  34. # else
  35. # define SYSCALL_ERROR_LABEL __syscall_error
  36. # endif
  37. # define DO_CALL(syscall_name, args) \
  38. addik r12,r0,SYS_ify (syscall_name); \
  39. brki r14,8; \
  40. addk r0,r0,r0;
  41. # undef PSEUDO
  42. # define PSEUDO(name, syscall_name, args) \
  43. .text; \
  44. ENTRY (name) \
  45. DO_CALL (syscall_name, args); \
  46. addik r12,r0,-4095; \
  47. cmpu r12,r12,r3; \
  48. bgei r12,SYSCALL_ERROR_LABEL;
  49. # undef PSEUDO_END
  50. # define PSEUDO_END(name) \
  51. SYSCALL_ERROR_HANDLER; \
  52. END (name)
  53. #ifdef __PIC__
  54. # define SYSCALL_ERROR_LABEL_DCL 0
  55. # if defined _LIBC_REENTRANT
  56. # define SYSCALL_ERROR_HANDLER \
  57. SYSCALL_ERROR_LABEL_DCL: \
  58. addik r1,r1,-16; \
  59. swi r15,r1,0; \
  60. swi r20,r1,8; \
  61. rsubk r3,r3,r0; \
  62. swi r3,r1,12; \
  63. mfs r20,rpc; \
  64. addik r20,r20,_GLOBAL_OFFSET_TABLE_+8; \
  65. brlid r15,__errno_location@PLT; \
  66. nop; \
  67. lwi r4,r1,12; \
  68. swi r4,r3,0; \
  69. lwi r20,r1,8; \
  70. lwi r15,r1,0; \
  71. addik r1,r1,16; \
  72. rtsd r15,8; \
  73. addik r3,r0,-1;
  74. # else /* !_LIBC_REENTRANT. */
  75. # define SYSCALL_ERROR_HANDLER \
  76. SYSCALL_ERROR_LABEL_DCL: \
  77. mfs r12,rpc; \
  78. addik r12,r12,_GLOBAL_OFFSET_TABLE_+8; \
  79. lwi r12,r12,errno@GOT; \
  80. rsubk r3,r3,r0; \
  81. swi r3,r12,0; \
  82. rtsd r15,8; \
  83. addik r3,r0,-1;
  84. # endif /* _LIBC_REENTRANT. */
  85. #else
  86. # define SYSCALL_ERROR_HANDLER /* Nothing here; code in sysdep.S is used. */
  87. #endif /* PIC. */
  88. #endif