sysdep.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /* Copyright (C) 1992, 1995, 1997, 1999, 2000, 2002, 2003, 2004
  2. Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. Contributed by Brendan Kehoe (brendan@zen.org).
  5. The GNU C Library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public
  7. License as published by the Free Software Foundation; either
  8. version 2.1 of the License, or (at your option) any later version.
  9. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with the GNU C Library; if not, see
  15. <http://www.gnu.org/licenses/>. */
  16. #ifndef _LINUX_MIPS_SYSDEP_H
  17. #define _LINUX_MIPS_SYSDEP_H 1
  18. #include <sgidefs.h>
  19. #include <common/sysdep.h>
  20. /* For Linux we can use the system call table in the header file
  21. /usr/include/asm/unistd.h
  22. of the kernel. But these symbols do not follow the SYS_* syntax
  23. so we have to redefine the `SYS_ify' macro here. */
  24. #undef SYS_ify
  25. #ifdef __STDC__
  26. # define SYS_ify(syscall_name) __NR_##syscall_name
  27. #else
  28. # define SYS_ify(syscall_name) __NR_/**/syscall_name
  29. #endif
  30. #ifdef __ASSEMBLER__
  31. #include <sys/regdef.h>
  32. #define ENTRY(name) \
  33. .globl name; \
  34. .align 2; \
  35. .ent name,0; \
  36. name##:
  37. #undef END
  38. #define END(function) \
  39. .end function; \
  40. .size function,.-function
  41. #define ret j ra ; nop
  42. #undef PSEUDO_END
  43. #define PSEUDO_END(sym) .end sym; .size sym,.-sym
  44. #define PSEUDO_NOERRNO(name, syscall_name, args) \
  45. .align 2; \
  46. ENTRY(name) \
  47. .set noreorder; \
  48. li v0, SYS_ify(syscall_name); \
  49. syscall
  50. #undef PSEUDO_END_NOERRNO
  51. #define PSEUDO_END_NOERRNO(sym) .end sym; .size sym,.-sym
  52. #define ret_NOERRNO ret
  53. #define PSEUDO_ERRVAL(name, syscall_name, args) \
  54. .align 2; \
  55. ENTRY(name) \
  56. .set noreorder; \
  57. li v0, SYS_ify(syscall_name); \
  58. syscall
  59. #undef PSEUDO_END_ERRVAL
  60. #define PSEUDO_END_ERRVAL(sym) .end sym; .size sym,.-sym
  61. #define r0 v0
  62. #define r1 v1
  63. /* The mips move insn is d,s. */
  64. #define MOVE(x,y) move y , x
  65. #if _MIPS_SIM == _ABIO32
  66. # define L(label) $L ## label
  67. #else
  68. # define L(label) .L ## label
  69. #endif
  70. /* Note that while it's better structurally, going back to call __syscall_error
  71. can make things confusing if you're debugging---it looks like it's jumping
  72. backwards into the previous fn. */
  73. #ifdef __PIC__
  74. #define PSEUDO(name, syscall_name, args) \
  75. .align 2; \
  76. 99: move a0, v0; \
  77. la t9,__syscall_error; \
  78. jr t9; \
  79. ENTRY(name) \
  80. .set noreorder; \
  81. .cpload t9; \
  82. li v0, SYS_ify(syscall_name); \
  83. syscall; \
  84. .set reorder; \
  85. bne a3, zero, 99b; \
  86. L(syse1):
  87. #else
  88. #define PSEUDO(name, syscall_name, args) \
  89. .set noreorder; \
  90. .align 2; \
  91. 99: move a0, v0; \
  92. j __syscall_error; \
  93. nop; \
  94. ENTRY(name) \
  95. .set noreorder; \
  96. li v0, SYS_ify(syscall_name); \
  97. syscall; \
  98. .set reorder; \
  99. bne a3, zero, 99b; \
  100. L(syse1):
  101. #endif
  102. /* We don't want the label for the error handler to be visible in the symbol
  103. table when we define it here. */
  104. #ifdef __PIC__
  105. # define SYSCALL_ERROR_LABEL 99b
  106. #endif
  107. #else /* ! __ASSEMBLER__ */
  108. /* Pointer mangling is not yet supported for MIPS. */
  109. #define PTR_MANGLE(var) (void) (var)
  110. #define PTR_DEMANGLE(var) (void) (var)
  111. #endif /* __ASSEMBLER__ */
  112. #endif /* _LINUX_MIPS_SYSDEP_H */