From 82addb1312f4f58a412a664228944009aa5cb569 Mon Sep 17 00:00:00 2001 From: Ariadne Conill Date: Fri, 21 Aug 2020 07:07:48 +0000 Subject: [PATCH] ada: musl support fixes --- gcc/ada/Makefile.rtl | 10 +++++----- gcc/ada/adaint.c | 34 +++++++++++++++++++--------------- gcc/ada/adaint.h | 10 ++++------ gcc/ada/terminals.c | 8 ++++---- 4 files changed, 32 insertions(+), 30 deletions(-) diff --git a/gcc/ada/Makefile.rtl b/gcc/ada/Makefile.rtl index aaf853e3a2a..e2dd3587ed5 100644 --- a/gcc/ada/Makefile.rtl +++ b/gcc/ada/Makefile.rtl @@ -1633,7 +1633,7 @@ ifeq ($(strip $(filter-out %86 linux%,$(target_cpu) $(target_os))),) s-intman.adb #include #endif + +#if defined (linux) || defined(__linux__) +#define _GNU_SOURCE 1 +#include +#endif #ifdef __PikeOS__ #define __BSD_VISIBLE 1 @@ -3446,7 +3451,6 @@ __gnat_lwp_self (void) #endif #if defined (__linux__) -#include /* glibc versions earlier than 2.7 do not define the routines to handle dynamically allocated CPU sets. For these targets, we use the static @@ -3456,7 +3460,7 @@ __gnat_lwp_self (void) /* Dynamic cpu sets */ -cpu_set_t * +void * __gnat_cpu_alloc (size_t count) { return CPU_ALLOC (count); @@ -3469,33 +3473,33 @@ __gnat_cpu_alloc_size (size_t count) } void -__gnat_cpu_free (cpu_set_t *set) +__gnat_cpu_free (void *set) { - CPU_FREE (set); + CPU_FREE ((cpu_set_t *) set); } void -__gnat_cpu_zero (size_t count, cpu_set_t *set) +__gnat_cpu_zero (size_t count, void *set) { - CPU_ZERO_S (count, set); + CPU_ZERO_S (count, (cpu_set_t *) set); } void -__gnat_cpu_set (int cpu, size_t count, cpu_set_t *set) +__gnat_cpu_set (int cpu, size_t count, void *set) { /* Ada handles CPU numbers starting from 1, while C identifies the first CPU by a 0, so we need to adjust. */ - CPU_SET_S (cpu - 1, count, set); + CPU_SET_S (cpu - 1, count, (cpu_set_t *) set); } #else /* !CPU_ALLOC */ /* Static cpu sets */ -cpu_set_t * +void * __gnat_cpu_alloc (size_t count ATTRIBUTE_UNUSED) { - return (cpu_set_t *) xmalloc (sizeof (cpu_set_t)); + return xmalloc (sizeof (cpu_set_t)); } size_t @@ -3505,23 +3509,23 @@ __gnat_cpu_alloc_size (size_t count ATTRIBUTE_UNUSED) } void -__gnat_cpu_free (cpu_set_t *set) +__gnat_cpu_free (void *set) { free (set); } void -__gnat_cpu_zero (size_t count ATTRIBUTE_UNUSED, cpu_set_t *set) +__gnat_cpu_zero (size_t count ATTRIBUTE_UNUSED, void *set) { - CPU_ZERO (set); + CPU_ZERO ((cpu_set_t *) set); } void -__gnat_cpu_set (int cpu, size_t count ATTRIBUTE_UNUSED, cpu_set_t *set) +__gnat_cpu_set (int cpu, size_t count ATTRIBUTE_UNUSED, void *set) { /* Ada handles CPU numbers starting from 1, while C identifies the first CPU by a 0, so we need to adjust. */ - CPU_SET (cpu - 1, set); + CPU_SET (cpu - 1, (cpu_set_t *) set); } #endif /* !CPU_ALLOC */ #endif /* __linux__ */ diff --git a/gcc/ada/adaint.h b/gcc/ada/adaint.h index 2631be5ad3e..d442f4bd6cd 100644 --- a/gcc/ada/adaint.h +++ b/gcc/ada/adaint.h @@ -321,13 +321,11 @@ extern void *__gnat_lwp_self (void); /* Routines for interface to required CPU set primitives */ -#include - -extern cpu_set_t *__gnat_cpu_alloc (size_t); +extern void * __gnat_cpu_alloc (size_t); extern size_t __gnat_cpu_alloc_size (size_t); -extern void __gnat_cpu_free (cpu_set_t *); -extern void __gnat_cpu_zero (size_t, cpu_set_t *); -extern void __gnat_cpu_set (int, size_t, cpu_set_t *); +extern void __gnat_cpu_free (void *); +extern void __gnat_cpu_zero (size_t, void *); +extern void __gnat_cpu_set (int, size_t, void *); #endif #if defined (_WIN32) diff --git a/gcc/ada/terminals.c b/gcc/ada/terminals.c index 32d30a49c7e..d960e32e2d0 100644 --- a/gcc/ada/terminals.c +++ b/gcc/ada/terminals.c @@ -1132,7 +1132,7 @@ __gnat_setup_winsize (void *desc ATTRIBUTE_UNUSED, /* POSIX does not specify how to open the master side of a terminal.Several methods are available (system specific): 1- using a cloning device (USE_CLONE_DEVICE) - 2- getpt (USE_GETPT) + 2- posix_openpt (USE_POSIX_OPENPT) 3- openpty (USE_OPENPTY) When using the cloning device method, the macro USE_CLONE_DEVICE should @@ -1146,7 +1146,7 @@ __gnat_setup_winsize (void *desc ATTRIBUTE_UNUSED, #if defined (__APPLE__) || defined (BSD) #define USE_OPENPTY #elif defined (__linux__) -#define USE_GETPT +#define USE_POSIX_OPENPT #elif defined (__sun__) #define USE_CLONE_DEVICE "/dev/ptmx" #elif defined (_AIX) @@ -1195,8 +1195,8 @@ allocate_pty_desc (pty_desc **desc) { int master_fd = -1; char *slave_name = NULL; -#ifdef USE_GETPT - master_fd = getpt (); +#if defined(USE_POSIX_OPENPT) + master_fd = posix_openpt(O_RDWR | O_NOCTTY); #elif defined (USE_OPENPTY) status = openpty (&master_fd, &slave_fd, NULL, NULL, NULL); #elif defined (USE_CLONE_DEVICE)