From: Arnaud Charlet Date: Thu, 18 Jul 2019 16:37:40 +0000 (+0000) Subject: Makefile.rtl, [...]: Introduce a "STANDALONE" mode where C runtime files do not have... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a6fc663e311b2b862373e4a4f3ee7d6836acb1a2;p=gcc.git Makefile.rtl, [...]: Introduce a "STANDALONE" mode where C runtime files do not have any dependency... * Makefile.rtl, expect.c, env.c, aux-io.c, mkdir.c, initialize.c, cstreams.c, raise.c, tracebak.c, adadecode.c, init.c, raise-gcc.c, argv.c, adaint.c, adaint.h, ctrl_c.c, sysdep.c, rtinit.c, cio.c, seh_init.c, exit.c, targext.c: Introduce a "STANDALONE" mode where C runtime files do not have any dependency on GCC include files. Remove unnecessary includes. Remove remaining references to VMS in runtime C file. * runtime.h: new File. From-SVN: r273576 --- diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index efd9d2fb371..ff3582f6837 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,14 @@ +2019-07-18 Arnaud Charlet + + * Makefile.rtl, expect.c, env.c, aux-io.c, mkdir.c, initialize.c, + cstreams.c, raise.c, tracebak.c, adadecode.c, init.c, raise-gcc.c, + argv.c, adaint.c, adaint.h, ctrl_c.c, sysdep.c, rtinit.c, cio.c, + seh_init.c, exit.c, targext.c: Introduce a "STANDALONE" mode where C + runtime files do not have any dependency on GCC include files. + Remove unnecessary includes. + Remove remaining references to VMS in runtime C file. + * runtime.h: new File. + 2019-07-13 Andreas Schwab * Makefile.rtl: Use g-sercom__linux.adb for all linuxes. diff --git a/gcc/ada/Makefile.rtl b/gcc/ada/Makefile.rtl index daee19a4ba5..6528df8114c 100644 --- a/gcc/ada/Makefile.rtl +++ b/gcc/ada/Makefile.rtl @@ -2610,7 +2610,7 @@ LIBGNAT_OBJS = adadecode.o adaint.o argv.o aux-io.o \ LIBGNAT_SRCS = $(patsubst %.o,%.c,$(LIBGNAT_OBJS)) \ adadecode.h adaint.h env.h gsocket.h raise.h standard.ads.h \ - tb-gcc.c libgnarl/thread.c $(EXTRA_LIBGNAT_SRCS) + tb-gcc.c runtime.h libgnarl/thread.c $(EXTRA_LIBGNAT_SRCS) # memtrack.o is special as not put into libgnat. GNATRTL_OBJS = $(GNATRTL_NONTASKING_OBJS) $(GNATRTL_TASKING_OBJS) \ diff --git a/gcc/ada/adadecode.c b/gcc/ada/adadecode.c index a574f3cf4a6..f87d421224f 100644 --- a/gcc/ada/adadecode.c +++ b/gcc/ada/adadecode.c @@ -29,15 +29,7 @@ * * ****************************************************************************/ - -#if defined(IN_RTS) -#include "tconfig.h" -#include "tsystem.h" -#elif defined(IN_GCC) -#include "config.h" -#include "system.h" -#endif - +#include "runtime.h" #include #include #include diff --git a/gcc/ada/adaint.c b/gcc/ada/adaint.c index 4a75b590911..fe8d9552d9b 100644 --- a/gcc/ada/adaint.c +++ b/gcc/ada/adaint.c @@ -88,8 +88,26 @@ #endif #ifdef IN_RTS + +#ifdef STANDALONE +#include +#include +#include +#include +#include +#include + +/* for CPU_SET/CPU_ZERO */ +#define _GNU_SOURCE +#define __USE_GNU + +#include "runtime.h" + +#else #include "tconfig.h" #include "tsystem.h" +#endif + #include #include #include diff --git a/gcc/ada/adaint.h b/gcc/ada/adaint.h index 2ae87669918..311e240dfcc 100644 --- a/gcc/ada/adaint.h +++ b/gcc/ada/adaint.h @@ -51,7 +51,7 @@ extern "C" { determine at compile time what support the system offers for large files. For now we just list the platforms we have manually tested. */ -#if defined (__GLIBC__) || defined (__sun__) || defined (__QNX__) +#if (defined (__GLIBC__) && !defined(STANDALONE)) || defined (__sun__) || defined (__QNX__) #define GNAT_FOPEN fopen64 #define GNAT_OPEN open64 #define GNAT_STAT stat64 diff --git a/gcc/ada/argv.c b/gcc/ada/argv.c index 3249c32cf31..ca82ed596e9 100644 --- a/gcc/ada/argv.c +++ b/gcc/ada/argv.c @@ -43,9 +43,8 @@ Ada.Command_Line.Environment package. */ #ifdef IN_RTS -#include "tconfig.h" -#include "tsystem.h" -#include +#include "runtime.h" +#include #else #include "config.h" #include "system.h" diff --git a/gcc/ada/aux-io.c b/gcc/ada/aux-io.c index b55a6f984aa..e022b65770c 100644 --- a/gcc/ada/aux-io.c +++ b/gcc/ada/aux-io.c @@ -31,10 +31,7 @@ #include -#ifdef IN_RTS -#include "tconfig.h" -#include "tsystem.h" -#else +#ifndef IN_RTS #include "config.h" #include "system.h" #endif diff --git a/gcc/ada/cio.c b/gcc/ada/cio.c index dd91a3e1d69..7fca41285c0 100644 --- a/gcc/ada/cio.c +++ b/gcc/ada/cio.c @@ -30,8 +30,7 @@ ****************************************************************************/ #ifdef IN_RTS -#include "tconfig.h" -#include "tsystem.h" +#include "runtime.h" #include #else #include "config.h" diff --git a/gcc/ada/cstreams.c b/gcc/ada/cstreams.c index e37070ddb78..92392fcbd1c 100644 --- a/gcc/ada/cstreams.c +++ b/gcc/ada/cstreams.c @@ -53,9 +53,7 @@ #endif #ifdef IN_RTS -#include "tconfig.h" -#include "tsystem.h" -#include +#include #else #include "config.h" #include "system.h" diff --git a/gcc/ada/ctrl_c.c b/gcc/ada/ctrl_c.c index 546faa70881..0e427ea5d26 100644 --- a/gcc/ada/ctrl_c.c +++ b/gcc/ada/ctrl_c.c @@ -29,11 +29,7 @@ * * ****************************************************************************/ -#ifdef IN_RTS -#include "tconfig.h" -#include "tsystem.h" -#include -#else +#ifndef IN_RTS #include "config.h" #include "system.h" #endif diff --git a/gcc/ada/env.c b/gcc/ada/env.c index 04e861e19e9..698b17708e1 100644 --- a/gcc/ada/env.c +++ b/gcc/ada/env.c @@ -30,15 +30,11 @@ ****************************************************************************/ #ifdef IN_RTS -# include "tconfig.h" -# include "tsystem.h" +# include "runtime.h" +# include +# include +# include -# include -# include -# include -# ifdef VMS -# include -# endif /* We don't have libiberty, so use malloc. */ # define xmalloc(S) malloc (S) #else /* IN_RTS */ @@ -109,89 +105,10 @@ __gnat_getenv (char *name, int *len, char **value) return; } -/* VMS specific declarations for set_env_value. */ - -#ifdef VMS - -typedef struct _ile3 -{ - unsigned short len, code; - __char_ptr32 adr; - __char_ptr32 retlen_adr; -} ile_s; - -#endif - void __gnat_setenv (char *name, char *value) { -#if defined (VMS) - struct dsc$descriptor_s name_desc; - $DESCRIPTOR (table_desc, "LNM$PROCESS"); - char *host_pathspec = value; - char *copy_pathspec; - int num_dirs_in_pathspec = 1; - char *ptr; - long status; - - name_desc.dsc$w_length = strlen (name); - name_desc.dsc$b_dtype = DSC$K_DTYPE_T; - name_desc.dsc$b_class = DSC$K_CLASS_S; - name_desc.dsc$a_pointer = name; /* ??? Danger, not 64bit safe. */ - - if (*host_pathspec == 0) - /* deassign */ - { - status = LIB$DELETE_LOGICAL (&name_desc, &table_desc); - /* no need to check status; if the logical name is not - defined, that's fine. */ - return; - } - - ptr = host_pathspec; - while (*ptr++) - if (*ptr == ',') - num_dirs_in_pathspec++; - - { - int i, status; - /* Alloca is guaranteed to be 32bit. */ - ile_s *ile_array = alloca (sizeof (ile_s) * (num_dirs_in_pathspec + 1)); - char *copy_pathspec = alloca (strlen (host_pathspec) + 1); - char *curr, *next; - - strcpy (copy_pathspec, host_pathspec); - curr = copy_pathspec; - for (i = 0; i < num_dirs_in_pathspec; i++) - { - next = strchr (curr, ','); - if (next == 0) - next = strchr (curr, 0); - - *next = 0; - ile_array[i].len = strlen (curr); - - /* Code 2 from lnmdef.h means it's a string. */ - ile_array[i].code = 2; - ile_array[i].adr = curr; - - /* retlen_adr is ignored. */ - ile_array[i].retlen_adr = 0; - curr = next + 1; - } - - /* Terminating item must be zero. */ - ile_array[i].len = 0; - ile_array[i].code = 0; - ile_array[i].adr = 0; - ile_array[i].retlen_adr = 0; - - status = LIB$SET_LOGICAL (&name_desc, 0, &table_desc, 0, ile_array); - if ((status & 1) != 1) - LIB$SIGNAL (status); - } - -#elif (defined (__vxworks) && defined (__RTP__)) || defined (__APPLE__) +#if (defined (__vxworks) && defined (__RTP__)) || defined (__APPLE__) setenv (name, value, 1); #else @@ -213,10 +130,7 @@ __gnat_setenv (char *name, char *value) char ** __gnat_environ (void) { -#if defined (VMS) || defined (RTX) - /* Not implemented */ - return NULL; -#elif defined (__MINGW32__) +#if defined (__MINGW32__) return _environ; #elif defined (__sun__) extern char **_environ; @@ -247,10 +161,7 @@ __gnat_environ (void) void __gnat_unsetenv (char *name) { -#if defined (VMS) - /* Not implemented */ - return; -#elif defined (__hpux__) || defined (__sun__) \ +#if defined (__hpux__) || defined (__sun__) \ || (defined (__vxworks) && ! defined (__RTP__)) \ || defined (_AIX) || defined (__Lynx__) @@ -306,10 +217,7 @@ void __gnat_unsetenv (char *name) void __gnat_clearenv (void) { -#if defined (VMS) - /* not implemented */ - return; -#elif defined (__sun__) \ +#if defined (__sun__) \ || (defined (__vxworks) && ! defined (__RTP__)) || defined (__Lynx__) \ || defined (__PikeOS__) /* On Solaris, VxWorks (not RTPs), and Lynx there is no system diff --git a/gcc/ada/exit.c b/gcc/ada/exit.c index 3ac35968946..3f6ef210e2f 100644 --- a/gcc/ada/exit.c +++ b/gcc/ada/exit.c @@ -29,21 +29,6 @@ * * ****************************************************************************/ -#ifdef __alpha_vxworks -#include "vxWorks.h" -#endif - -#ifdef IN_RTS -#include "tconfig.h" -#include "tsystem.h" -#include -#else -#include "config.h" -#include "system.h" -#endif - -#include "adaint.h" - #ifdef __cplusplus extern "C" { #endif diff --git a/gcc/ada/expect.c b/gcc/ada/expect.c index 76fce788fc9..349af3f789d 100644 --- a/gcc/ada/expect.c +++ b/gcc/ada/expect.c @@ -29,14 +29,11 @@ * * ****************************************************************************/ -#ifdef __alpha_vxworks -#include "vxWorks.h" -#endif - #ifdef IN_RTS #define POSIX -#include "tconfig.h" -#include "tsystem.h" +#include "runtime.h" +#include + #else #include "config.h" #include "system.h" diff --git a/gcc/ada/init.c b/gcc/ada/init.c index 300a7e1c1dd..f7e830e9259 100644 --- a/gcc/ada/init.c +++ b/gcc/ada/init.c @@ -54,8 +54,14 @@ #endif #ifdef IN_RTS + +#ifdef STANDALONE +#include "runtime.h" +#else #include "tconfig.h" #include "tsystem.h" +#endif + #include /* We don't have libiberty, so use malloc. */ @@ -463,6 +469,7 @@ void fake_linux_sigemptyset (sigset_t *set) void __gnat_adjust_context_for_raise (int signo ATTRIBUTE_UNUSED, void *ucontext) { +#ifndef STANDALONE mcontext_t *mcontext = &((ucontext_t *) ucontext)->uc_mcontext; /* On the i386 and x86-64 architectures, stack checking is performed by @@ -513,6 +520,7 @@ __gnat_adjust_context_for_raise (int signo ATTRIBUTE_UNUSED, void *ucontext) mcontext->arm_pc+=1; #endif #endif +#endif } #endif diff --git a/gcc/ada/initialize.c b/gcc/ada/initialize.c index ab6d81d651e..0e52feb1340 100644 --- a/gcc/ada/initialize.c +++ b/gcc/ada/initialize.c @@ -41,8 +41,7 @@ #endif #ifdef IN_RTS -#include "tconfig.h" -#include "tsystem.h" +#include "runtime.h" /* We don't have libiberty, so use malloc. */ #define xmalloc(S) malloc (S) #define xrealloc(V,S) realloc (V,S) diff --git a/gcc/ada/mkdir.c b/gcc/ada/mkdir.c index d06147673f6..e0efccec36f 100644 --- a/gcc/ada/mkdir.c +++ b/gcc/ada/mkdir.c @@ -35,8 +35,7 @@ #endif /* __vxworks */ #ifdef IN_RTS -#include "tconfig.h" -#include "tsystem.h" +#include "runtime.h" #include #else #include "config.h" diff --git a/gcc/ada/raise-gcc.c b/gcc/ada/raise-gcc.c index 6092a87b881..c15547dbc95 100644 --- a/gcc/ada/raise-gcc.c +++ b/gcc/ada/raise-gcc.c @@ -39,11 +39,11 @@ /* Don't use fancy_abort. */ # undef abort #else -# ifndef CERT +# if !defined(CERT) && !defined(STANDALONE) # include "tconfig.h" # include "tsystem.h" # else -# define ATTRIBUTE_UNUSED __attribute__((unused)) +# include "runtime.h" # define HAVE_GETIPINFO 1 # endif #endif @@ -115,6 +115,10 @@ extern void __gnat_unhandled_except_handler (_Unwind_Exception *); /* Called in case of error during propagation. */ extern void __gnat_raise_abort (void) __attribute__ ((noreturn)); #define abort() __gnat_raise_abort() + +#elif defined(STANDALONE) +#include +#define inhibit_libc #endif #include "unwind-pe.h" diff --git a/gcc/ada/raise.c b/gcc/ada/raise.c index 480a0eabca5..bf8a8797afc 100644 --- a/gcc/ada/raise.c +++ b/gcc/ada/raise.c @@ -33,8 +33,7 @@ is shared between all exception handling mechanisms. */ #ifdef IN_RTS -#include "tconfig.h" -#include "tsystem.h" +#include "runtime.h" #else #include "config.h" #include "system.h" @@ -56,16 +55,6 @@ extern "C" { void __gnat_unhandled_terminate (void) { -#ifdef VMS - /* Special termination handling for VMS */ - long prvhnd; - - /* Remove the exception vector so it won't intercept any errors - in the call to exit, and go into and endless loop */ - - SYS$SETEXV (1, 0, 3, &prvhnd); -#endif - /* Default termination handling */ __gnat_os_exit (1); } diff --git a/gcc/ada/rtinit.c b/gcc/ada/rtinit.c index 1df98f81cf2..5c9c5ecc80e 100644 --- a/gcc/ada/rtinit.c +++ b/gcc/ada/rtinit.c @@ -41,8 +41,6 @@ #endif #ifdef IN_RTS -#include "tconfig.h" -#include "tsystem.h" /* We don't have libiberty, so use malloc. */ #define xmalloc(S) malloc (S) #define xrealloc(V,S) realloc (V,S) diff --git a/gcc/ada/runtime.h b/gcc/ada/runtime.h new file mode 100644 index 00000000000..df42730c0a5 --- /dev/null +++ b/gcc/ada/runtime.h @@ -0,0 +1,44 @@ +/**************************************************************************** + * * + * GNAT COMPILER COMPONENTS * + * * + * RUNTIME * + * * + * C Header File * + * * + * Copyright (C) 2019, Free Software Foundation, Inc. * + * * + * GNAT is free software; you can redistribute it and/or modify it under * + * terms of the GNU General Public License as published by the Free Soft- * + * ware Foundation; either version 3, or (at your option) any later ver- * + * sion. GNAT is distributed in the hope that it will be useful, but WITH- * + * OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * + * or FITNESS FOR A PARTICULAR PURPOSE. * + * * + * As a special exception under Section 7 of GPL version 3, you are granted * + * additional permissions described in the GCC Runtime Library Exception, * + * version 3.1, as published by the Free Software Foundation. * + * * + * You should have received a copy of the GNU General Public License and * + * a copy of the GCC Runtime Library Exception along with this program; * + * see the files COPYING3 and COPYING.RUNTIME respectively. If not, see * + * . * + * * + * GNAT was originally developed by the GNAT team at New York University. * + * Extensive contributions were provided by Ada Core Technologies Inc. * + * * + ****************************************************************************/ + +/* This file provides common definitions used by GNAT C runtime files. */ + +#ifdef __vxworks +#include "vxWorks.h" +#endif /* __vxworks */ + +#ifndef ATTRIBUTE_UNUSED +#define ATTRIBUTE_UNUSED __attribute__((unused)) +#endif + +#ifndef ATTRIBUTE_NORETURN +#define ATTRIBUTE_NORETURN __attribute__((noreturn)) +#endif diff --git a/gcc/ada/seh_init.c b/gcc/ada/seh_init.c index fa9a69346f6..2926605caa9 100644 --- a/gcc/ada/seh_init.c +++ b/gcc/ada/seh_init.c @@ -39,8 +39,8 @@ #endif #ifdef IN_RTS -#include "tconfig.h" -#include "tsystem.h" + +#include "runtime.h" /* We don't have libiberty, so use malloc. */ #define xmalloc(S) malloc (S) diff --git a/gcc/ada/sysdep.c b/gcc/ada/sysdep.c index 66c29d3718a..1e1f5eeb5e6 100644 --- a/gcc/ada/sysdep.c +++ b/gcc/ada/sysdep.c @@ -54,8 +54,10 @@ #ifdef IN_RTS #define POSIX -#include "tconfig.h" -#include "tsystem.h" +#include "runtime.h" +#include +#include + #include #include #else diff --git a/gcc/ada/targext.c b/gcc/ada/targext.c index 39d75d16e94..d761b2a5a56 100644 --- a/gcc/ada/targext.c +++ b/gcc/ada/targext.c @@ -36,14 +36,21 @@ the file must be compiled with IN_GCC defined, even for the library. */ #ifdef IN_RTS + +#ifndef STANDALONE #include "tconfig.h" #include "tsystem.h" +#endif + #else #include "config.h" #include "system.h" #endif + +#ifndef STANDALONE #include "coretypes.h" #include "tm.h" +#endif #ifndef TARGET_OBJECT_SUFFIX #define TARGET_OBJECT_SUFFIX ".o" diff --git a/gcc/ada/tracebak.c b/gcc/ada/tracebak.c index a43dc4dc461..9e74282e11f 100644 --- a/gcc/ada/tracebak.c +++ b/gcc/ada/tracebak.c @@ -50,14 +50,10 @@ extern "C" { #endif -#ifdef __alpha_vxworks -#include "vxWorks.h" -#endif - #ifdef IN_RTS #define POSIX -#include "tconfig.h" -#include "tsystem.h" +#include "runtime.h" +#include #else #include "config.h" #include "system.h"