sysdep.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /* Assembler macro definitions. OpenRISC version.
  2. Copyright (C) 2022-2026 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library. If not, see
  14. <https://www.gnu.org/licenses/>. */
  15. #include <sysdeps/generic/sysdep.h>
  16. #include <features.h>
  17. #if defined __ASSEMBLER__ || defined REQUEST_ASSEMBLER_MACROS
  18. /* Make use of .size directive. */
  19. #define ASM_SIZE_DIRECTIVE(name) .size name,.-name;
  20. /* Define an entry point visible from C. */
  21. #define ENTRY(name) \
  22. .globl C_SYMBOL_NAME(name); \
  23. .type C_SYMBOL_NAME(name),@function; \
  24. .align 4; \
  25. C_LABEL(name) \
  26. cfi_startproc; \
  27. CALL_MCOUNT
  28. #undef END
  29. #define END(name) \
  30. cfi_endproc; \
  31. ASM_SIZE_DIRECTIVE(name)
  32. /* Since C identifiers are not normally prefixed with an underscore
  33. on this system, the asm identifier `syscall_error' intrudes on the
  34. C name space. Make sure we use an innocuous name. */
  35. #define syscall_error __syscall_error
  36. /* If compiled for profiling, call `mcount' at the start of each function. */
  37. #ifdef PROF
  38. # ifdef __PIC__
  39. # define CALL_MCOUNT \
  40. l.addi r1, r1, -8; \
  41. l.sw 0(r1), r9; \
  42. l.sw 4(r1), r3; \
  43. l.ori r3, r9, 0; \
  44. l.j plt(_mcount); \
  45. l.nop; \
  46. l.lwz r9, 0(r1); \
  47. l.lwz r3, 4(r1); \
  48. l.addi r1, r1, 8;
  49. # else
  50. # define CALL_MCOUNT \
  51. l.addi r1, r1, -8; \
  52. l.sw 0(r1), r9; \
  53. l.sw 4(r1), r3; \
  54. l.ori r3, r9, 0; \
  55. l.movhi r15, hi(_mcount); \
  56. l.ori r15, r15, lo(_mcount); \
  57. l.jr r15; \
  58. l.nop; \
  59. l.lwz r9, 0(r1); \
  60. l.lwz r3, 4(r1); \
  61. l.addi r1, r1, 8;
  62. # endif
  63. #else
  64. # define CALL_MCOUNT /* Do nothing. */
  65. #endif
  66. /* Local label name for asm code. */
  67. #define L(name) .L##name
  68. #endif /* __ASSEMBLER__ */