sysdep.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /* Copyright (C) 2011-2014 Free Software Foundation, Inc.
  2. The GNU C Library is free software; you can redistribute it and/or
  3. modify it under the terms of the GNU Lesser General Public License as
  4. published by the Free Software Foundation; either version 2.1 of the
  5. License, or (at your option) any later version.
  6. The GNU C Library is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  9. Lesser General Public License for more details.
  10. You should have received a copy of the GNU Lesser General Public
  11. License along with the GNU C Library; if not, see
  12. <http://www.gnu.org/licenses/>. */
  13. #ifndef _LINUX_OR1K_SYSDEP_H
  14. #define _LINUX_OR1K_SYSDEP_H 1
  15. #include <common/sysdep.h>
  16. #include <sys/syscall.h>
  17. /* In order to get __set_errno() definition in INLINE_SYSCALL. */
  18. #ifndef __ASSEMBLER__
  19. #include <errno.h>
  20. #endif
  21. #undef SYS_ify
  22. #define SYS_ify(syscall_name) (__NR_##syscall_name)
  23. #ifdef __ASSEMBLER__
  24. /* Local label name for asm code. */
  25. #define L(name) .L##name
  26. #undef ret_ERRVAL
  27. #define ret_ERRVAL l.jr r9; l.nop
  28. #define ret_NOERRNO l.jr r9; l.nop
  29. #undef DO_CALL
  30. #define DO_CALL(syscall_name) \
  31. l.addi r11, r0, SYS_ify (syscall_name); \
  32. l.sys 1; \
  33. l.nop
  34. #define PSEUDO(name, syscall_name, args) \
  35. ENTRY (name); \
  36. DO_CALL(syscall_name); \
  37. /* if -4096 < ret < 0 holds, it's an error */ \
  38. l.sfgeui r11, 0xf001; \
  39. l.bf L(pseudo_end); \
  40. l.nop
  41. #define PSEUDO_NOERRNO(name, syscall_name, args) \
  42. ENTRY (name); \
  43. DO_CALL(syscall_name)
  44. #define PSEUDO_END(name) \
  45. L(pseudo_end): \
  46. l.j SYSCALL_ERROR_NAME; \
  47. l.ori r3,r11,0; \
  48. END (name)
  49. #define PSEUDO_END_NOERRNO(name) \
  50. END (name)
  51. #ifndef PIC
  52. /* For static code, on error jump to __syscall_error directly. */
  53. # define SYSCALL_ERROR_NAME __syscall_error
  54. #elif NOT_IN_libc
  55. /* Use the internal name for libc/libpthread shared objects. */
  56. # define SYSCALL_ERROR_NAME __GI___syscall_error
  57. #else
  58. /* Otherwise, on error do a full PLT jump. */
  59. # define SYSCALL_ERROR_NAME plt(__syscall_error)
  60. #endif
  61. /* Make use of .size directive. */
  62. #define ASM_SIZE_DIRECTIVE(name) .size name,.-name;
  63. /* Define an entry point visible from C. */
  64. #define ENTRY(name) \
  65. .globl C_SYMBOL_NAME(name); \
  66. .type C_SYMBOL_NAME(name),@function; \
  67. .align 4; \
  68. C_LABEL(name) \
  69. cfi_startproc; \
  70. #undef END
  71. #define END(name) \
  72. cfi_endproc; \
  73. ASM_SIZE_DIRECTIVE(name)
  74. /* Since C identifiers are not normally prefixed with an underscore
  75. on this system, the asm identifier `syscall_error' intrudes on the
  76. C name space. Make sure we use an innocuous name. */
  77. #define syscall_error __syscall_error
  78. /* Specify the size in bytes of a machine register. */
  79. #define REGSIZE 4
  80. #endif /* __ASSEMBLER__ */
  81. #endif /* linux/or1k/sysdep.h */