+2019-07-18 Arnaud Charlet <charlet@adacore.com>
+
+ * 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 <schwab@linux-m68k.org>
* Makefile.rtl: Use g-sercom__linux.adb for all linuxes.
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) \
* *
****************************************************************************/
-
-#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 <string.h>
#include <stdio.h>
#include <ctype.h>
#endif
#ifdef IN_RTS
+
+#ifdef STANDALONE
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+
+/* for CPU_SET/CPU_ZERO */
+#define _GNU_SOURCE
+#define __USE_GNU
+
+#include "runtime.h"
+
+#else
#include "tconfig.h"
#include "tsystem.h"
+#endif
+
#include <sys/stat.h>
#include <fcntl.h>
#include <time.h>
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
Ada.Command_Line.Environment package. */
#ifdef IN_RTS
-#include "tconfig.h"
-#include "tsystem.h"
-#include <sys/stat.h>
+#include "runtime.h"
+#include <string.h>
#else
#include "config.h"
#include "system.h"
#include <stdio.h>
-#ifdef IN_RTS
-#include "tconfig.h"
-#include "tsystem.h"
-#else
+#ifndef IN_RTS
#include "config.h"
#include "system.h"
#endif
****************************************************************************/
#ifdef IN_RTS
-#include "tconfig.h"
-#include "tsystem.h"
+#include "runtime.h"
#include <sys/stat.h>
#else
#include "config.h"
#endif
#ifdef IN_RTS
-#include "tconfig.h"
-#include "tsystem.h"
-#include <sys/stat.h>
+#include <string.h>
#else
#include "config.h"
#include "system.h"
* *
****************************************************************************/
-#ifdef IN_RTS
-#include "tconfig.h"
-#include "tsystem.h"
-#include <sys/stat.h>
-#else
+#ifndef IN_RTS
#include "config.h"
#include "system.h"
#endif
****************************************************************************/
#ifdef IN_RTS
-# include "tconfig.h"
-# include "tsystem.h"
+# include "runtime.h"
+# include <stdio.h>
+# include <stdlib.h>
+# include <string.h>
-# include <sys/stat.h>
-# include <fcntl.h>
-# include <time.h>
-# ifdef VMS
-# include <unixio.h>
-# endif
/* We don't have libiberty, so use malloc. */
# define xmalloc(S) malloc (S)
#else /* IN_RTS */
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
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;
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__)
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
* *
****************************************************************************/
-#ifdef __alpha_vxworks
-#include "vxWorks.h"
-#endif
-
-#ifdef IN_RTS
-#include "tconfig.h"
-#include "tsystem.h"
-#include <sys/stat.h>
-#else
-#include "config.h"
-#include "system.h"
-#endif
-
-#include "adaint.h"
-
#ifdef __cplusplus
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 <unistd.h>
+
#else
#include "config.h"
#include "system.h"
#endif
#ifdef IN_RTS
+
+#ifdef STANDALONE
+#include "runtime.h"
+#else
#include "tconfig.h"
#include "tsystem.h"
+#endif
+
#include <sys/stat.h>
/* We don't have libiberty, so use malloc. */
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
mcontext->arm_pc+=1;
#endif
#endif
+#endif
}
#endif
#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)
#endif /* __vxworks */
#ifdef IN_RTS
-#include "tconfig.h"
-#include "tsystem.h"
+#include "runtime.h"
#include <sys/stat.h>
#else
#include "config.h"
/* 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
/* Called in case of error during propagation. */
extern void __gnat_raise_abort (void) __attribute__ ((noreturn));
#define abort() __gnat_raise_abort()
+
+#elif defined(STANDALONE)
+#include <stdlib.h>
+#define inhibit_libc
#endif
#include "unwind-pe.h"
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"
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);
}
#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)
--- /dev/null
+/****************************************************************************
+ * *
+ * 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 *
+ * <http://www.gnu.org/licenses/>. *
+ * *
+ * 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
#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)
#ifdef IN_RTS
#define POSIX
-#include "tconfig.h"
-#include "tsystem.h"
+#include "runtime.h"
+#include <string.h>
+#include <unistd.h>
+
#include <fcntl.h>
#include <sys/stat.h>
#else
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"
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 <stddef.h>
#else
#include "config.h"
#include "system.h"