0015-Change-definitions-of-F_GETLK-F_SETLK-F_SETLKW.patch 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. From fb2d200423299843818884801e2598dd643ec834 Mon Sep 17 00:00:00 2001
  2. From: Stefan O'Rear <sorear@fastmail.com>
  3. Date: Wed, 9 Sep 2020 11:57:54 -0700
  4. Subject: [PATCH 15/16] Change definitions of F_GETLK, F_SETLK, F_SETLKW
  5. * gdb HEAD wants ELF_NFPREG, so I set it in bits/user.h to the value
  6. gdb needs. (glibc does #define ELF_NFPREG NFPREG and expects gdb
  7. to define NFPREG. I don't get this.)
  8. * Restore accidentally removed errno setting in waitpid, fixes a gdb
  9. assertion failure.
  10. * Zero IPC_64 because the kernel only recognizes one set of IPC commands.
  11. * Copy the IPC_TIME64 bits from arch/arm/bits to trigger the musl code
  12. for fixing time64 IPC_STAT results. I'm not super happy with this,
  13. maybe there should be a new mechanism in musl for fixing IPC_STAT for
  14. unconditionally-time64 architectures.
  15. * riscv32 _does_ provide both F_GETLK and F_GETLK32; make sure we use
  16. the right one.
  17. Signed-off-by: Stefan O'Rear <sorear@fastmail.com>
  18. Signed-off-by: Khem Raj <raj.khem@gmail.com>
  19. ---
  20. arch/riscv32/bits/fcntl.h | 7 ++++---
  21. arch/riscv32/bits/ipcstat.h | 1 +
  22. arch/riscv32/bits/msg.h | 18 ++++++++++++++++++
  23. arch/riscv32/bits/sem.h | 18 ++++++++++++++++++
  24. arch/riscv32/bits/shm.h | 31 +++++++++++++++++++++++++++++++
  25. arch/riscv32/bits/user.h | 1 +
  26. arch/riscv32/syscall_arch.h | 2 ++
  27. arch/riscv64/bits/user.h | 1 +
  28. src/process/waitpid.c | 2 +-
  29. 9 files changed, 77 insertions(+), 4 deletions(-)
  30. create mode 100644 arch/riscv32/bits/ipcstat.h
  31. create mode 100644 arch/riscv32/bits/msg.h
  32. create mode 100644 arch/riscv32/bits/sem.h
  33. create mode 100644 arch/riscv32/bits/shm.h
  34. diff --git a/arch/riscv32/bits/fcntl.h b/arch/riscv32/bits/fcntl.h
  35. index ecb4d18f..66f84fac 100644
  36. --- a/arch/riscv32/bits/fcntl.h
  37. +++ b/arch/riscv32/bits/fcntl.h
  38. @@ -24,14 +24,15 @@
  39. #define F_SETFD 2
  40. #define F_GETFL 3
  41. #define F_SETFL 4
  42. -#define F_GETLK 5
  43. -#define F_SETLK 6
  44. -#define F_SETLKW 7
  45. #define F_SETOWN 8
  46. #define F_GETOWN 9
  47. #define F_SETSIG 10
  48. #define F_GETSIG 11
  49. +#define F_GETLK 12
  50. +#define F_SETLK 13
  51. +#define F_SETLKW 14
  52. +
  53. #define F_SETOWN_EX 15
  54. #define F_GETOWN_EX 16
  55. diff --git a/arch/riscv32/bits/ipcstat.h b/arch/riscv32/bits/ipcstat.h
  56. new file mode 100644
  57. index 00000000..4f4fcb0c
  58. --- /dev/null
  59. +++ b/arch/riscv32/bits/ipcstat.h
  60. @@ -0,0 +1 @@
  61. +#define IPC_STAT 0x102
  62. diff --git a/arch/riscv32/bits/msg.h b/arch/riscv32/bits/msg.h
  63. new file mode 100644
  64. index 00000000..7bbbb2bf
  65. --- /dev/null
  66. +++ b/arch/riscv32/bits/msg.h
  67. @@ -0,0 +1,18 @@
  68. +struct msqid_ds {
  69. + struct ipc_perm msg_perm;
  70. + unsigned long __msg_stime_lo;
  71. + unsigned long __msg_stime_hi;
  72. + unsigned long __msg_rtime_lo;
  73. + unsigned long __msg_rtime_hi;
  74. + unsigned long __msg_ctime_lo;
  75. + unsigned long __msg_ctime_hi;
  76. + unsigned long msg_cbytes;
  77. + msgqnum_t msg_qnum;
  78. + msglen_t msg_qbytes;
  79. + pid_t msg_lspid;
  80. + pid_t msg_lrpid;
  81. + unsigned long __unused[2];
  82. + time_t msg_stime;
  83. + time_t msg_rtime;
  84. + time_t msg_ctime;
  85. +};
  86. diff --git a/arch/riscv32/bits/sem.h b/arch/riscv32/bits/sem.h
  87. new file mode 100644
  88. index 00000000..544e3d2a
  89. --- /dev/null
  90. +++ b/arch/riscv32/bits/sem.h
  91. @@ -0,0 +1,18 @@
  92. +struct semid_ds {
  93. + struct ipc_perm sem_perm;
  94. + unsigned long __sem_otime_lo;
  95. + unsigned long __sem_otime_hi;
  96. + unsigned long __sem_ctime_lo;
  97. + unsigned long __sem_ctime_hi;
  98. +#if __BYTE_ORDER == __LITTLE_ENDIAN
  99. + unsigned short sem_nsems;
  100. + char __sem_nsems_pad[sizeof(long)-sizeof(short)];
  101. +#else
  102. + char __sem_nsems_pad[sizeof(long)-sizeof(short)];
  103. + unsigned short sem_nsems;
  104. +#endif
  105. + long __unused3;
  106. + long __unused4;
  107. + time_t sem_otime;
  108. + time_t sem_ctime;
  109. +};
  110. diff --git a/arch/riscv32/bits/shm.h b/arch/riscv32/bits/shm.h
  111. new file mode 100644
  112. index 00000000..725fb469
  113. --- /dev/null
  114. +++ b/arch/riscv32/bits/shm.h
  115. @@ -0,0 +1,31 @@
  116. +#define SHMLBA 4096
  117. +
  118. +struct shmid_ds {
  119. + struct ipc_perm shm_perm;
  120. + size_t shm_segsz;
  121. + unsigned long __shm_atime_lo;
  122. + unsigned long __shm_atime_hi;
  123. + unsigned long __shm_dtime_lo;
  124. + unsigned long __shm_dtime_hi;
  125. + unsigned long __shm_ctime_lo;
  126. + unsigned long __shm_ctime_hi;
  127. + pid_t shm_cpid;
  128. + pid_t shm_lpid;
  129. + unsigned long shm_nattch;
  130. + unsigned long __pad1;
  131. + unsigned long __pad2;
  132. + unsigned long __pad3;
  133. + time_t shm_atime;
  134. + time_t shm_dtime;
  135. + time_t shm_ctime;
  136. +};
  137. +
  138. +struct shminfo {
  139. + unsigned long shmmax, shmmin, shmmni, shmseg, shmall, __unused[4];
  140. +};
  141. +
  142. +struct shm_info {
  143. + int __used_ids;
  144. + unsigned long shm_tot, shm_rss, shm_swp;
  145. + unsigned long __swap_attempts, __swap_successes;
  146. +};
  147. diff --git a/arch/riscv32/bits/user.h b/arch/riscv32/bits/user.h
  148. index 2da743ea..0d37de0b 100644
  149. --- a/arch/riscv32/bits/user.h
  150. +++ b/arch/riscv32/bits/user.h
  151. @@ -1,5 +1,6 @@
  152. #include <signal.h>
  153. #define ELF_NGREG 32
  154. +#define ELF_NFPREG 33
  155. typedef unsigned long elf_greg_t, elf_gregset_t[ELF_NGREG];
  156. typedef union __riscv_mc_fp_state elf_fpregset_t;
  157. diff --git a/arch/riscv32/syscall_arch.h b/arch/riscv32/syscall_arch.h
  158. index 9e916c76..c507f15f 100644
  159. --- a/arch/riscv32/syscall_arch.h
  160. +++ b/arch/riscv32/syscall_arch.h
  161. @@ -76,3 +76,5 @@ static inline long __syscall6(long n, long a, long b, long c, long d, long e, lo
  162. /* We don't have a clock_gettime function.
  163. #define VDSO_CGT_SYM "__vdso_clock_gettime"
  164. #define VDSO_CGT_VER "LINUX_2.6" */
  165. +
  166. +#define IPC_64 0
  167. diff --git a/arch/riscv64/bits/user.h b/arch/riscv64/bits/user.h
  168. index 2da743ea..0d37de0b 100644
  169. --- a/arch/riscv64/bits/user.h
  170. +++ b/arch/riscv64/bits/user.h
  171. @@ -1,5 +1,6 @@
  172. #include <signal.h>
  173. #define ELF_NGREG 32
  174. +#define ELF_NFPREG 33
  175. typedef unsigned long elf_greg_t, elf_gregset_t[ELF_NGREG];
  176. typedef union __riscv_mc_fp_state elf_fpregset_t;
  177. diff --git a/src/process/waitpid.c b/src/process/waitpid.c
  178. index e5ff27ca..9de4073f 100644
  179. --- a/src/process/waitpid.c
  180. +++ b/src/process/waitpid.c
  181. @@ -3,5 +3,5 @@
  182. pid_t waitpid(pid_t pid, int *status, int options)
  183. {
  184. - return __wait4(pid, status, options, 0, 1);
  185. + return __syscall_ret(__wait4(pid, status, options, 0, 1));
  186. }
  187. --
  188. 2.29.2