galeb

Једноставна статичка дистрибуција заснована на musl-у
git clone https://git.sr.ht/~strahinja/galeb
Дневник | Датотеке | Референце | ПРОЧИТАЈМЕ | ЛИЦЕНЦА

0029-ada-musl-support-fixes.patch (7307B)


      1 From 82addb1312f4f58a412a664228944009aa5cb569 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 aaf853e3a2a..e2dd3587ed5 100644
     15 --- a/gcc/ada/Makefile.rtl
     16 +++ b/gcc/ada/Makefile.rtl
     17 @@ -1633,7 +1633,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 @@ -2258,7 +2258,7 @@ ifeq ($(strip $(filter-out powerpc% linux%,$(target_cpu) $(target_os))),)
     27    s-tasinf.adb<libgnarl/s-tasinf__linux.adb \
     28    s-taspri.ads<libgnarl/s-taspri__posix.ads \
     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 @@ -2289,7 +2289,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 @@ -2504,7 +2504,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    $(GNATRTL_128BIT_PAIRS) \
     53 @@ -2608,7 +2608,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    $(GNATRTL_128BIT_PAIRS) \
     62 diff --git a/gcc/ada/adaint.c b/gcc/ada/adaint.c
     63 index 591d033fbca..a485cbf15b9 100644
     64 --- a/gcc/ada/adaint.c
     65 +++ b/gcc/ada/adaint.c
     66 @@ -91,6 +91,11 @@
     67  #include <sys/param.h>
     68  #include <sys/pstat.h>
     69  #endif
     70 + 
     71 +#if defined (linux) || defined(__linux__)
     72 +#define _GNU_SOURCE 1
     73 +#include <sched.h>
     74 +#endif
     75  
     76  #ifdef __PikeOS__
     77  #define __BSD_VISIBLE 1
     78 @@ -3446,7 +3451,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 @@ -3456,7 +3460,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 @@ -3469,33 +3473,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 @@ -3505,23 +3509,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 2631be5ad3e..d442f4bd6cd 100644
    168 --- a/gcc/ada/adaint.h
    169 +++ b/gcc/ada/adaint.h
    170 @@ -321,13 +321,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 32d30a49c7e..d960e32e2d0 100644
    190 --- a/gcc/ada/terminals.c
    191 +++ b/gcc/ada/terminals.c
    192 @@ -1132,7 +1132,7 @@ __gnat_setup_winsize (void *desc ATTRIBUTE_UNUSED,
    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 @@ -1146,7 +1146,7 @@ __gnat_setup_winsize (void *desc ATTRIBUTE_UNUSED,
    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 @@ -1195,8 +1195,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)