0027-ada-musl-support-fixes.patch (7336B)
1 From 21692d89e7876dcaecea3e3c961c6504be4a83e9 Mon Sep 17 00:00:00 2001 2 From: Ariadne Conill <ariadne@dereferenced.org> 3 Date: Fri, 21 Aug 2020 07:07:48 +0000 4 Subject: [PATCH] ada: musl support fixes 5 6 --- 7 gcc/ada/Makefile.rtl | 10 +++++----- 8 gcc/ada/adaint.c | 34 +++++++++++++++++++--------------- 9 gcc/ada/adaint.h | 10 ++++------ 10 gcc/ada/terminals.c | 8 ++++---- 11 4 files changed, 32 insertions(+), 30 deletions(-) 12 13 diff --git a/gcc/ada/Makefile.rtl b/gcc/ada/Makefile.rtl 14 index 55ff9b0f3d5..0fadf4e4b79 100644 15 --- a/gcc/ada/Makefile.rtl 16 +++ b/gcc/ada/Makefile.rtl 17 @@ -1533,7 +1533,7 @@ ifeq ($(strip $(filter-out %86 linux%,$(target_cpu) $(target_os))),) 18 s-intman.adb<libgnarl/s-intman__posix.adb \ 19 s-tpopsp.adb<libgnarl/s-tpopsp__tls.adb \ 20 $(TRASYM_DWARF_UNIX_PAIRS) \ 21 - s-tsmona.adb<libgnat/s-tsmona__linux.adb \ 22 + s-tsmona.adb<libgnat/s-tsmona.adb \ 23 a-exetim.adb<libgnarl/a-exetim__posix.adb \ 24 a-exetim.ads<libgnarl/a-exetim__default.ads \ 25 s-linux.ads<libgnarl/s-linux.ads \ 26 @@ -2083,7 +2083,7 @@ ifeq ($(strip $(filter-out powerpc% linux%,$(target_cpu) $(target_os))),) 27 s-osinte.adb<libgnarl/s-osinte__posix.adb \ 28 s-tpopsp.adb<libgnarl/s-tpopsp__tls.adb \ 29 $(TRASYM_DWARF_UNIX_PAIRS) \ 30 - s-tsmona.adb<libgnat/s-tsmona__linux.adb \ 31 + s-tsmona.adb<libgnat/s-tsmona.adb \ 32 $(ATOMICS_TARGET_PAIRS) \ 33 $(ATOMICS_BUILTINS_TARGET_PAIRS) \ 34 system.ads<libgnat/system-linux-ppc.ads 35 @@ -2112,7 +2112,7 @@ ifeq ($(strip $(filter-out powerpc% linux%,$(target_cpu) $(target_os))),) 36 endif 37 38 # ARM linux, GNU eabi 39 -ifeq ($(strip $(filter-out arm% linux-gnueabi%,$(target_cpu) $(target_os))),) 40 +ifeq ($(strip $(filter-out arm% linux-gnueabi% linux-musleabi% linux-muslgnueabi%,$(target_cpu) $(target_os))),) 41 LIBGNAT_TARGET_PAIRS = \ 42 a-intnam.ads<libgnarl/a-intnam__linux.ads \ 43 s-inmaop.adb<libgnarl/s-inmaop__posix.adb \ 44 @@ -2305,7 +2305,7 @@ ifeq ($(strip $(filter-out %ia64 linux%,$(target_cpu) $(target_os))),) 45 s-tpopsp.adb<libgnarl/s-tpopsp__tls.adb \ 46 s-taspri.ads<libgnarl/s-taspri__posix-noaltstack.ads \ 47 $(TRASYM_DWARF_UNIX_PAIRS) \ 48 - s-tsmona.adb<libgnat/s-tsmona__linux.adb \ 49 + s-tsmona.adb<libgnat/s-tsmona.adb \ 50 $(ATOMICS_TARGET_PAIRS) \ 51 $(ATOMICS_BUILTINS_TARGET_PAIRS) \ 52 system.ads<libgnat/system-linux-ia64.ads 53 @@ -2401,7 +2401,7 @@ ifeq ($(strip $(filter-out %x86_64 linux%,$(target_cpu) $(target_os))),) 54 s-tpopsp.adb<libgnarl/s-tpopsp__tls.adb \ 55 s-taspri.ads<libgnarl/s-taspri__posix.ads \ 56 $(TRASYM_DWARF_UNIX_PAIRS) \ 57 - s-tsmona.adb<libgnat/s-tsmona__linux.adb \ 58 + s-tsmona.adb<libgnat/s-tsmona.adb \ 59 $(ATOMICS_TARGET_PAIRS) \ 60 $(X86_64_TARGET_PAIRS) \ 61 system.ads<libgnat/system-linux-x86.ads 62 diff --git a/gcc/ada/adaint.c b/gcc/ada/adaint.c 63 index 595abf87d65..00858c24f53 100644 64 --- a/gcc/ada/adaint.c 65 +++ b/gcc/ada/adaint.c 66 @@ -90,6 +90,11 @@ 67 #include <sys/param.h> 68 #include <sys/pstat.h> 69 #endif 70 + 71 +#if defined (linux) 72 +#define _GNU_SOURCE 1 73 +#include <sched.h> 74 +#endif 75 76 #ifdef __PikeOS__ 77 #define __BSD_VISIBLE 1 78 @@ -3308,7 +3313,6 @@ __gnat_lwp_self (void) 79 #endif 80 81 #if defined (__linux__) 82 -#include <sched.h> 83 84 /* glibc versions earlier than 2.7 do not define the routines to handle 85 dynamically allocated CPU sets. For these targets, we use the static 86 @@ -3318,7 +3322,7 @@ __gnat_lwp_self (void) 87 88 /* Dynamic cpu sets */ 89 90 -cpu_set_t * 91 +void * 92 __gnat_cpu_alloc (size_t count) 93 { 94 return CPU_ALLOC (count); 95 @@ -3331,33 +3335,33 @@ __gnat_cpu_alloc_size (size_t count) 96 } 97 98 void 99 -__gnat_cpu_free (cpu_set_t *set) 100 +__gnat_cpu_free (void *set) 101 { 102 - CPU_FREE (set); 103 + CPU_FREE ((cpu_set_t *) set); 104 } 105 106 void 107 -__gnat_cpu_zero (size_t count, cpu_set_t *set) 108 +__gnat_cpu_zero (size_t count, void *set) 109 { 110 - CPU_ZERO_S (count, set); 111 + CPU_ZERO_S (count, (cpu_set_t *) set); 112 } 113 114 void 115 -__gnat_cpu_set (int cpu, size_t count, cpu_set_t *set) 116 +__gnat_cpu_set (int cpu, size_t count, void *set) 117 { 118 /* Ada handles CPU numbers starting from 1, while C identifies the first 119 CPU by a 0, so we need to adjust. */ 120 - CPU_SET_S (cpu - 1, count, set); 121 + CPU_SET_S (cpu - 1, count, (cpu_set_t *) set); 122 } 123 124 #else /* !CPU_ALLOC */ 125 126 /* Static cpu sets */ 127 128 -cpu_set_t * 129 +void * 130 __gnat_cpu_alloc (size_t count ATTRIBUTE_UNUSED) 131 { 132 - return (cpu_set_t *) xmalloc (sizeof (cpu_set_t)); 133 + return xmalloc (sizeof (cpu_set_t)); 134 } 135 136 size_t 137 @@ -3367,23 +3371,23 @@ __gnat_cpu_alloc_size (size_t count ATTRIBUTE_UNUSED) 138 } 139 140 void 141 -__gnat_cpu_free (cpu_set_t *set) 142 +__gnat_cpu_free (void *set) 143 { 144 free (set); 145 } 146 147 void 148 -__gnat_cpu_zero (size_t count ATTRIBUTE_UNUSED, cpu_set_t *set) 149 +__gnat_cpu_zero (size_t count ATTRIBUTE_UNUSED, void *set) 150 { 151 - CPU_ZERO (set); 152 + CPU_ZERO ((cpu_set_t *) set); 153 } 154 155 void 156 -__gnat_cpu_set (int cpu, size_t count ATTRIBUTE_UNUSED, cpu_set_t *set) 157 +__gnat_cpu_set (int cpu, size_t count ATTRIBUTE_UNUSED, void *set) 158 { 159 /* Ada handles CPU numbers starting from 1, while C identifies the first 160 CPU by a 0, so we need to adjust. */ 161 - CPU_SET (cpu - 1, set); 162 + CPU_SET (cpu - 1, (cpu_set_t *) set); 163 } 164 #endif /* !CPU_ALLOC */ 165 #endif /* __linux__ */ 166 diff --git a/gcc/ada/adaint.h b/gcc/ada/adaint.h 167 index 311e240dfcc..1c4d0050103 100644 168 --- a/gcc/ada/adaint.h 169 +++ b/gcc/ada/adaint.h 170 @@ -316,13 +316,11 @@ extern void *__gnat_lwp_self (void); 171 172 /* Routines for interface to required CPU set primitives */ 173 174 -#include <sched.h> 175 - 176 -extern cpu_set_t *__gnat_cpu_alloc (size_t); 177 +extern void * __gnat_cpu_alloc (size_t); 178 extern size_t __gnat_cpu_alloc_size (size_t); 179 -extern void __gnat_cpu_free (cpu_set_t *); 180 -extern void __gnat_cpu_zero (size_t, cpu_set_t *); 181 -extern void __gnat_cpu_set (int, size_t, cpu_set_t *); 182 +extern void __gnat_cpu_free (void *); 183 +extern void __gnat_cpu_zero (size_t, void *); 184 +extern void __gnat_cpu_set (int, size_t, void *); 185 #endif 186 187 #if defined (_WIN32) 188 diff --git a/gcc/ada/terminals.c b/gcc/ada/terminals.c 189 index af4417fab90..bab6bf3ca87 100644 190 --- a/gcc/ada/terminals.c 191 +++ b/gcc/ada/terminals.c 192 @@ -1145,7 +1145,7 @@ __gnat_setup_winsize (void *desc, int rows, int columns) 193 /* POSIX does not specify how to open the master side of a terminal.Several 194 methods are available (system specific): 195 1- using a cloning device (USE_CLONE_DEVICE) 196 - 2- getpt (USE_GETPT) 197 + 2- posix_openpt (USE_POSIX_OPENPT) 198 3- openpty (USE_OPENPTY) 199 200 When using the cloning device method, the macro USE_CLONE_DEVICE should 201 @@ -1159,7 +1159,7 @@ __gnat_setup_winsize (void *desc, int rows, int columns) 202 #if defined (__APPLE__) || defined (BSD) 203 #define USE_OPENPTY 204 #elif defined (__linux__) 205 -#define USE_GETPT 206 +#define USE_POSIX_OPENPT 207 #elif defined (__sun__) 208 #define USE_CLONE_DEVICE "/dev/ptmx" 209 #elif defined (_AIX) 210 @@ -1208,8 +1208,8 @@ allocate_pty_desc (pty_desc **desc) { 211 int master_fd = -1; 212 char *slave_name = NULL; 213 214 -#ifdef USE_GETPT 215 - master_fd = getpt (); 216 +#if defined(USE_POSIX_OPENPT) 217 + master_fd = posix_openpt(O_RDWR | O_NOCTTY); 218 #elif defined (USE_OPENPTY) 219 status = openpty (&master_fd, &slave_fd, NULL, NULL, NULL); 220 #elif defined (USE_CLONE_DEVICE) 221 -- 222 2.31.1 223