0007-add-header-files-for-vector-support.patch 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. From 850779729c6da29f45bc10b2fa4f500c9edfd19b Mon Sep 17 00:00:00 2001
  2. From: "max.ma" <max.ma@starfivetech.com>
  3. Date: Tue, 6 Sep 2022 02:21:53 -0700
  4. Subject: [PATCH 07/19] add header files for vector support
  5. cx
  6. ---
  7. sysdeps/riscv/rtld-global-offsets.sym | 7 ++++
  8. sysdeps/unix/sysv/linux/riscv/bits/hwcap.h | 31 +++++++++++++++
  9. .../sysv/linux/riscv/bits/pthread_stack_min.h | 21 ++++++++++
  10. sysdeps/unix/sysv/linux/riscv/bits/sigstack.h | 32 +++++++++++++++
  11. .../linux/riscv/sysconf-pthread_stack_min.h | 39 +++++++++++++++++++
  12. 5 files changed, 130 insertions(+)
  13. create mode 100644 sysdeps/riscv/rtld-global-offsets.sym
  14. create mode 100644 sysdeps/unix/sysv/linux/riscv/bits/hwcap.h
  15. create mode 100644 sysdeps/unix/sysv/linux/riscv/bits/pthread_stack_min.h
  16. create mode 100644 sysdeps/unix/sysv/linux/riscv/bits/sigstack.h
  17. create mode 100644 sysdeps/unix/sysv/linux/riscv/sysconf-pthread_stack_min.h
  18. diff --git a/sysdeps/riscv/rtld-global-offsets.sym b/sysdeps/riscv/rtld-global-offsets.sym
  19. new file mode 100644
  20. index 0000000000..ff4e97f2a6
  21. --- /dev/null
  22. +++ b/sysdeps/riscv/rtld-global-offsets.sym
  23. @@ -0,0 +1,7 @@
  24. +#define SHARED 1
  25. +
  26. +#include <ldsodefs.h>
  27. +
  28. +#define rtld_global_ro_offsetof(mem) offsetof (struct rtld_global_ro, mem)
  29. +
  30. +RTLD_GLOBAL_RO_DL_HWCAP_OFFSET rtld_global_ro_offsetof (_dl_hwcap)
  31. diff --git a/sysdeps/unix/sysv/linux/riscv/bits/hwcap.h b/sysdeps/unix/sysv/linux/riscv/bits/hwcap.h
  32. new file mode 100644
  33. index 0000000000..dbd101fa2e
  34. --- /dev/null
  35. +++ b/sysdeps/unix/sysv/linux/riscv/bits/hwcap.h
  36. @@ -0,0 +1,31 @@
  37. +/* Defines for bits in AT_HWCAP. RISC-V Linux version.
  38. + Copyright (C) 2022 Free Software Foundation, Inc.
  39. + This file is part of the GNU C Library.
  40. +
  41. + The GNU C Library is free software; you can redistribute it and/or
  42. + modify it under the terms of the GNU Lesser General Public
  43. + License as published by the Free Software Foundation; either
  44. + version 2.1 of the License, or (at your option) any later version.
  45. +
  46. + The GNU C Library is distributed in the hope that it will be useful,
  47. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  48. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  49. + Lesser General Public License for more details.
  50. +
  51. + You should have received a copy of the GNU Lesser General Public
  52. + License along with the GNU C Library; if not, see
  53. + <http://www.gnu.org/licenses/>. */
  54. +
  55. +#if !defined (_SYS_AUXV_H) && !defined (_LINUX_RISCV_SYSDEP_H)
  56. +# error "Never include <bits/hwcap.h> directly; use <sys/auxv.h> instead."
  57. +#endif
  58. +
  59. +/* The following must match the kernel's <asm/hwcap.h>. */
  60. +#define HWCAP_ISA_I 0x100 //(1 << ('I' - 'A'))
  61. +#define HWCAP_ISA_M 0x1000 //(1 << ('M' - 'A'))
  62. +#define HWCAP_ISA_A 0x1 //(1 << ('A' - 'A'))
  63. +#define HWCAP_ISA_F 0x20 //(1 << ('F' - 'A'))
  64. +#define HWCAP_ISA_D 0x8 //(1 << ('D' - 'A'))
  65. +#define HWCAP_ISA_C 0x4 //(1 << ('C' - 'A'))
  66. +#define HWCAP_ISA_V 0x200000 //(1 << ('V' - 'A'))
  67. +
  68. diff --git a/sysdeps/unix/sysv/linux/riscv/bits/pthread_stack_min.h b/sysdeps/unix/sysv/linux/riscv/bits/pthread_stack_min.h
  69. new file mode 100644
  70. index 0000000000..0ab7feb4a7
  71. --- /dev/null
  72. +++ b/sysdeps/unix/sysv/linux/riscv/bits/pthread_stack_min.h
  73. @@ -0,0 +1,21 @@
  74. +/* Definition of PTHREAD_STACK_MIN. Linux/riscv version.
  75. + Copyright (C) 2022 Free Software Foundation, Inc.
  76. +
  77. + This file is part of the GNU C Library.
  78. +
  79. + The GNU C Library is free software; you can redistribute it and/or
  80. + modify it under the terms of the GNU Lesser General Public License as
  81. + published by the Free Software Foundation; either version 2.1 of the
  82. + License, or (at your option) any later version.
  83. +
  84. + The GNU C Library is distributed in the hope that it will be useful,
  85. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  86. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  87. + Lesser General Public License for more details.
  88. +
  89. + You should have received a copy of the GNU Lesser General Public
  90. + License along with the GNU C Library. If not, see
  91. + <https://www.gnu.org/licenses/>. */
  92. +
  93. +/* Minimum size for a thread. We are free to choose a reasonable value. */
  94. +#define PTHREAD_STACK_MIN 20480
  95. diff --git a/sysdeps/unix/sysv/linux/riscv/bits/sigstack.h b/sysdeps/unix/sysv/linux/riscv/bits/sigstack.h
  96. new file mode 100644
  97. index 0000000000..c75ddc03b0
  98. --- /dev/null
  99. +++ b/sysdeps/unix/sysv/linux/riscv/bits/sigstack.h
  100. @@ -0,0 +1,32 @@
  101. +/* sigstack, sigaltstack definitions.
  102. + Copyright (C) 2022 Free Software Foundation, Inc.
  103. + This file is part of the GNU C Library.
  104. +
  105. + The GNU C Library is free software; you can redistribute it and/or
  106. + modify it under the terms of the GNU Lesser General Public
  107. + License as published by the Free Software Foundation; either
  108. + version 2.1 of the License, or (at your option) any later version.
  109. +
  110. + The GNU C Library is distributed in the hope that it will be useful,
  111. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  112. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  113. + Lesser General Public License for more details.
  114. +
  115. + You should have received a copy of the GNU Lesser General Public
  116. + License along with the GNU C Library; if not, see
  117. + <https://www.gnu.org/licenses/>. */
  118. +
  119. +#ifndef _BITS_SIGSTACK_H
  120. +#define _BITS_SIGSTACK_H 1
  121. +
  122. +#if !defined _SIGNAL_H && !defined _SYS_UCONTEXT_H
  123. +# error "Never include this file directly. Use <signal.h> instead"
  124. +#endif
  125. +
  126. +/* Minimum stack size (5k+256 bytes) for a signal handler. */
  127. +#define MINSIGSTKSZ 5376
  128. +
  129. +/* System default stack size. */
  130. +#define SIGSTKSZ 16384
  131. +
  132. +#endif /* bits/sigstack.h */
  133. diff --git a/sysdeps/unix/sysv/linux/riscv/sysconf-pthread_stack_min.h b/sysdeps/unix/sysv/linux/riscv/sysconf-pthread_stack_min.h
  134. new file mode 100644
  135. index 0000000000..53ba6a1142
  136. --- /dev/null
  137. +++ b/sysdeps/unix/sysv/linux/riscv/sysconf-pthread_stack_min.h
  138. @@ -0,0 +1,39 @@
  139. +/* __get_pthread_stack_min (). Linux version.
  140. + Copyright (C) 2021 Free Software Foundation, Inc.
  141. + This file is part of the GNU C Library.
  142. +
  143. + The GNU C Library is free software; you can redistribute it and/or
  144. + modify it under the terms of the GNU Lesser General Public
  145. + License as published by the Free Software Foundation; either
  146. + version 2.1 of the License, or (at your option) any later version.
  147. +
  148. + The GNU C Library is distributed in the hope that it will be useful,
  149. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  150. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  151. + Lesser General Public License for more details.
  152. +
  153. + You should have received a copy of the GNU Lesser General Public
  154. + License along with the GNU C Library; if not, see
  155. + <https://www.gnu.org/licenses/>. */
  156. +
  157. +/* Return sysconf (_SC_THREAD_STACK_MIN). */
  158. +
  159. +static inline long int
  160. +__get_pthread_stack_min (void)
  161. +{
  162. + /* sysconf (_SC_THREAD_STACK_MIN) >= sysconf (_SC_MINSIGSTKSZ). */
  163. + long int pthread_stack_min = GLRO(dl_minsigstacksize) * 4;
  164. + assert (pthread_stack_min != 0);
  165. + _Static_assert (__builtin_constant_p (PTHREAD_STACK_MIN),
  166. + "PTHREAD_STACK_MIN is constant");
  167. + /* Return MAX (PTHREAD_STACK_MIN, pthread_stack_min). */
  168. + if (pthread_stack_min < PTHREAD_STACK_MIN)
  169. + pthread_stack_min = PTHREAD_STACK_MIN;
  170. + /* We have a private interface, __pthread_get_minstack@GLIBC_PRIVATE
  171. + which returns a larger size that includes the required TLS variable
  172. + space which has been determined at startup. For sysconf here we are
  173. + conservative and don't include the space required for TLS access.
  174. + Eventually the TLS variable space will not be part of the stack
  175. + (Bug 11787). */
  176. + return pthread_stack_min;
  177. +}
  178. --
  179. 2.25.1