]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/ada/adaint.h
[Ada] Bump copyright year
[thirdparty/gcc.git] / gcc / ada / adaint.h
CommitLineData
d23b8f57
RK
1/****************************************************************************
2 * *
3 * GNAT COMPILER COMPONENTS *
4 * *
5 * A D A I N T *
6 * *
d23b8f57
RK
7 * C Header File *
8 * *
4b490c1e 9 * Copyright (C) 1992-2020, Free Software Foundation, Inc. *
d23b8f57
RK
10 * *
11 * GNAT is free software; you can redistribute it and/or modify it under *
12 * terms of the GNU General Public License as published by the Free Soft- *
748086b7 13 * ware Foundation; either version 3, or (at your option) any later ver- *
d23b8f57
RK
14 * sion. GNAT is distributed in the hope that it will be useful, but WITH- *
15 * OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *
748086b7
JJ
16 * or FITNESS FOR A PARTICULAR PURPOSE. *
17 * *
18 * As a special exception under Section 7 of GPL version 3, you are granted *
19 * additional permissions described in the GCC Runtime Library Exception, *
20 * version 3.1, as published by the Free Software Foundation. *
21 * *
22 * You should have received a copy of the GNU General Public License and *
23 * a copy of the GCC Runtime Library Exception along with this program; *
24 * see the files COPYING3 and COPYING.RUNTIME respectively. If not, see *
25 * <http://www.gnu.org/licenses/>. *
d23b8f57
RK
26 * *
27 * GNAT was originally developed by the GNAT team at New York University. *
71ff80dc 28 * Extensive contributions were provided by Ada Core Technologies Inc. *
d23b8f57
RK
29 * *
30 ****************************************************************************/
31
9e9bd455
LG
32#ifdef __cplusplus
33extern "C" {
34#endif
35
0022d9e3 36#include <sys/stat.h>
c4039eb0 37#include <stdio.h>
0022d9e3 38
7e8338d8 39#if defined (_WIN32) || defined (__CYGWIN__)
0022d9e3
PO
40#include "mingw32.h"
41#endif
42
d23b8f57
RK
43#include <dirent.h>
44
fa5537cb 45/* Constants used for the form parameter encoding values */
ffec8e81
AC
46#define Encoding_UTF8 0 /* UTF-8 */
47#define Encoding_8bits 1 /* Standard 8bits, CP_ACP on Windows. */
48#define Encoding_Unspecified 2 /* Based on GNAT_CODE_PAGE env variable. */
fa5537cb 49
8d12c865
RD
50/* Large file support. It is unclear what portable mechanism we can use to
51 determine at compile time what support the system offers for large files.
52 For now we just list the platforms we have manually tested. */
03456e44 53
a6fc663e 54#if (defined (__GLIBC__) && !defined(STANDALONE)) || defined (__sun__) || defined (__QNX__)
f6c7fcc0 55#define GNAT_FOPEN fopen64
2b9fbec9 56#define GNAT_OPEN open64
f6c7fcc0
DK
57#define GNAT_STAT stat64
58#define GNAT_FSTAT fstat64
59#define GNAT_LSTAT lstat64
60#define GNAT_STRUCT_STAT struct stat64
24228312
AC
61
62#elif defined(_WIN32)
63#define GNAT_FOPEN fopen64
64#define GNAT_OPEN open
65#define GNAT_STAT stat64
66#define GNAT_FSTAT fstat64
67#define GNAT_LSTAT lstat
68#define GNAT_STRUCT_STAT struct stat64
69
be035558
AC
70#elif defined(__APPLE__)
71
72# include <TargetConditionals.h>
73
74# if TARGET_IPHONE_SIMULATOR
75 /* On iOS (simulator or not), the stat structure is the 64 bit one.
76 But the simulator uses the MacOS X syscalls that aren't 64 bit.
77 Fix this interfacing issue here. */
78 int fstat64(int, struct stat *);
79 int stat64(const char *, struct stat *);
80 int lstat64(const char *, struct stat *);
81# define GNAT_STAT stat64
82# define GNAT_FSTAT fstat64
83# define GNAT_LSTAT lstat64
84# else
85# define GNAT_STAT stat
86# define GNAT_FSTAT fstat
87# define GNAT_LSTAT lstat
88# endif
89
90# define GNAT_FOPEN fopen
91# define GNAT_OPEN open
92# define GNAT_STRUCT_STAT struct stat
93
03456e44 94#else
f6c7fcc0 95#define GNAT_FOPEN fopen
2b9fbec9 96#define GNAT_OPEN open
f6c7fcc0
DK
97#define GNAT_STAT stat
98#define GNAT_FSTAT fstat
99#define GNAT_LSTAT lstat
100#define GNAT_STRUCT_STAT struct stat
03456e44
AC
101#endif
102
ae65d635
AC
103/* Type corresponding to GNAT.OS_Lib.OS_Time */
104#if defined (_WIN64)
105typedef long long OS_Time;
106#else
107typedef long OS_Time;
108#endif
d23b8f57 109
fd7215d7 110#define __int64 long long
be42aa71 111GNAT_STRUCT_STAT;
fd7215d7 112
48263c9a
EB
113/* A lazy cache for the attributes of a file. On some systems, a single call to
114 stat() will give all this information, so it is better than doing a system
115 call every time. On other systems this require several system calls.
116*/
117
118struct file_attributes {
c6d2191a
AC
119 int error;
120 /* Errno value returned by stat()/fstat(). If non-zero, other fields should
121 * be considered as invalid.
122 */
123
96867674 124 unsigned char exists;
48263c9a 125
96867674
AC
126 unsigned char writable;
127 unsigned char readable;
128 unsigned char executable;
48263c9a 129
96867674
AC
130 unsigned char symbolic_link;
131 unsigned char regular;
132 unsigned char directory;
48263c9a
EB
133
134 OS_Time timestamp;
148c744a 135 __int64 file_length;
48263c9a
EB
136};
137/* WARNING: changing the size here might require changing the constant
138 * File_Attributes_Size in osint.ads (which should be big enough to
139 * fit the above struct on any system)
140 */
141
fbf5a39b 142extern int __gnat_max_path_len;
fa5537cb 143extern OS_Time __gnat_current_time (void);
9392454c 144extern void __gnat_current_time_string (char *);
d7598e11
PO
145extern void __gnat_to_gm_time (OS_Time *, int *, int *,
146 int *, int *,
147 int *, int *);
c3d01e19
PO
148extern void __gnat_to_os_time (OS_Time *, int, int, int,
149 int, int, int);
fbf5a39b
AC
150extern int __gnat_get_maximum_file_name_length (void);
151extern int __gnat_get_switches_case_sensitive (void);
152extern int __gnat_get_file_names_case_sensitive (void);
0e35524d 153extern int __gnat_get_env_vars_case_sensitive (void);
fbf5a39b
AC
154extern char __gnat_get_default_identifier_character_set (void);
155extern void __gnat_get_current_dir (char *, int *);
156extern void __gnat_get_object_suffix_ptr (int *,
157 const char **);
158extern void __gnat_get_executable_suffix_ptr (int *,
159 const char **);
160extern void __gnat_get_debuggable_suffix_ptr (int *,
161 const char **);
162extern int __gnat_readlink (char *, char *,
163 size_t);
164extern int __gnat_symlink (char *, char *);
165extern int __gnat_try_lock (char *, char *);
166extern int __gnat_open_new (char *, int);
167extern int __gnat_open_new_temp (char *, int);
e01934b7 168extern int __gnat_mkdir (char *, int);
fbf5a39b 169extern int __gnat_stat (char *,
f6c7fcc0 170 GNAT_STRUCT_STAT *);
991395ab
AC
171extern int __gnat_unlink (char *);
172extern int __gnat_rename (char *, char *);
4e0079cc 173extern int __gnat_chdir (char *);
468ee337 174extern int __gnat_rmdir (char *);
991395ab 175
4d49c6e1 176extern FILE *__gnat_fopen (char *, char *, int);
d7598e11 177extern FILE *__gnat_freopen (char *, char *, FILE *,
4d49c6e1 178 int);
479f9059 179extern int __gnat_open (char *, int);
fbf5a39b
AC
180extern int __gnat_open_read (char *, int);
181extern int __gnat_open_rw (char *, int);
182extern int __gnat_open_create (char *, int);
e6f69614 183extern int __gnat_create_output_file (char *);
fb468a94
AC
184extern int __gnat_create_output_file_new (char *);
185
fbf5a39b 186extern int __gnat_open_append (char *, int);
935a9145 187extern long __gnat_file_length_long (int);
148c744a
PO
188extern __int64 __gnat_file_length (int);
189extern __int64 __gnat_named_file_length (char *);
fbf5a39b 190extern void __gnat_tmp_name (char *);
0022d9e3
PO
191extern DIR *__gnat_opendir (char *);
192extern char *__gnat_readdir (DIR *, char *, int *);
193extern int __gnat_closedir (DIR *);
fbf5a39b 194extern int __gnat_readdir_is_thread_safe (void);
aa720a54
AC
195
196extern OS_Time __gnat_file_time_name (char *);
197extern OS_Time __gnat_file_time_fd (int);
198/* return -1 in case of error */
199
fbf5a39b 200extern void __gnat_set_file_time_name (char *, time_t);
0022d9e3 201
48263c9a
EB
202extern int __gnat_dup (int);
203extern int __gnat_dup2 (int, int);
204extern int __gnat_file_exists (char *);
205extern int __gnat_is_regular_file (char *);
206extern int __gnat_is_absolute_path (char *,int);
207extern int __gnat_is_directory (char *);
fbf5a39b
AC
208extern int __gnat_is_writable_file (char *);
209extern int __gnat_is_readable_file (char *name);
48263c9a 210extern int __gnat_is_executable_file (char *name);
0640c7d1
AC
211extern int __gnat_is_write_accessible_file (char *name);
212extern int __gnat_is_read_accessible_file (char *name);
48263c9a 213
c6d2191a
AC
214extern void __gnat_reset_attributes (struct file_attributes *);
215extern int __gnat_error_attributes (struct file_attributes *);
148c744a 216extern __int64 __gnat_file_length_attr (int, char *, struct file_attributes *);
48263c9a
EB
217extern OS_Time __gnat_file_time_name_attr (char *, struct file_attributes *);
218extern OS_Time __gnat_file_time_fd_attr (int, struct file_attributes *);
219extern int __gnat_file_exists_attr (char *, struct file_attributes *);
220extern int __gnat_is_regular_file_attr (char *, struct file_attributes *);
221extern int __gnat_is_directory_attr (char *, struct file_attributes *);
222extern int __gnat_is_readable_file_attr (char *, struct file_attributes *);
223extern int __gnat_is_writable_file_attr (char *, struct file_attributes *);
224extern int __gnat_is_executable_file_attr (char *, struct file_attributes *);
225extern int __gnat_is_symbolic_link_attr (char *, struct file_attributes *);
226
8b79ad42 227extern void __gnat_set_non_writable (char *name);
fbf5a39b 228extern void __gnat_set_writable (char *name);
d2d8b2a7 229extern void __gnat_set_executable (char *name, int);
43540ec6
AC
230extern void __gnat_set_readable (char *name);
231extern void __gnat_set_non_readable (char *name);
fbf5a39b
AC
232extern int __gnat_is_symbolic_link (char *name);
233extern int __gnat_portable_spawn (char *[]);
234extern int __gnat_portable_no_block_spawn (char *[]);
235extern int __gnat_portable_wait (int *);
36357cf3 236extern int __gnat_portable_no_block_wait (int *);
876f1624 237extern int __gnat_current_process_id (void);
fbf5a39b 238extern char *__gnat_locate_exec (char *, char *);
876f1624 239extern char *__gnat_locate_exec_on_path (char *);
fbf5a39b
AC
240extern char *__gnat_locate_regular_file (char *, char *);
241extern void __gnat_maybe_glob_args (int *, char ***);
242extern void __gnat_os_exit (int);
fbf5a39b
AC
243extern char *__gnat_get_libraries_from_registry (void);
244extern int __gnat_to_canonical_file_list_init (char *, int);
245extern char *__gnat_to_canonical_file_list_next (void);
246extern void __gnat_to_canonical_file_list_free (void);
247extern char *__gnat_to_canonical_dir_spec (char *, int);
248extern char *__gnat_to_canonical_file_spec (char *);
249extern char *__gnat_to_host_dir_spec (char *, int);
250extern char *__gnat_to_host_file_spec (char *);
251extern char *__gnat_to_canonical_path_spec (char *);
252extern void __gnat_adjust_os_resource_limits (void);
fa5537cb 253extern void convert_addresses (const char *, void *, int,
fbf5a39b
AC
254 void *, int *);
255extern int __gnat_copy_attribs (char *, char *, int);
256extern int __gnat_feof (FILE *);
257extern int __gnat_ferror (FILE *);
258extern int __gnat_fileno (FILE *);
259extern int __gnat_is_regular_file_fd (int);
260extern FILE *__gnat_constant_stderr (void);
261extern FILE *__gnat_constant_stdin (void);
262extern FILE *__gnat_constant_stdout (void);
263extern char *__gnat_full_name (char *, char *);
d23b8f57 264
fbf5a39b
AC
265extern int __gnat_arg_count (void);
266extern int __gnat_len_arg (int);
267extern void __gnat_fill_arg (char *, int);
268extern int __gnat_env_count (void);
269extern int __gnat_len_env (int);
270extern void __gnat_fill_env (char *, int);
d23b8f57
RK
271
272/* Routines for interface to scanf and printf functions for integer values */
273
fbf5a39b
AC
274extern int get_int (void);
275extern void put_int (int);
276extern void put_int_stderr (int);
277extern int get_char (void);
278extern void put_char (int);
279extern void put_char_stderr (int);
280extern char *mktemp (char *);
d23b8f57 281
fbf5a39b 282extern void __gnat_set_exit_status (int);
d23b8f57 283
fbf5a39b
AC
284extern int __gnat_expect_fork (void);
285extern void __gnat_expect_portable_execvp (char *, char *[]);
286extern int __gnat_pipe (int *);
287extern int __gnat_expect_poll (int *, int, int, int *);
288extern void __gnat_set_binary_mode (int);
289extern void __gnat_set_text_mode (int);
18f2c460 290extern void __gnat_set_mode (int,int);
fbf5a39b 291extern char *__gnat_ttyname (int);
efdfd311 292extern int __gnat_lseek (int, long, int);
cc892b2c 293extern int __gnat_set_close_on_exec (int, int);
f5a0cbf1
AC
294extern int __gnat_dup (int);
295extern int __gnat_dup2 (int, int);
d23b8f57 296
fd7215d7
AC
297/* large file support */
298extern __int64 __gnat_ftell64 (FILE *);
299extern int __gnat_fseek64 (FILE *, __int64, int);
300
7a259f2e
VC
301extern int __gnat_number_of_cpus (void);
302
d7598e11
PO
303extern void __gnat_os_filename (char *, char *, char *,
304 int *, char *, int *);
b7c9777e
AC
305
306extern char * __gnat_locate_executable_file (char *, char *);
307extern char * __gnat_locate_file_with_predicate (char *, char *,
308 int (*)(char*));
309
3c55062f 310#if defined (__ANDROID__)
329be64b 311#undef __linux__
3c55062f
BB
312extern void *__gnat_lwp_self (void);
313
329be64b 314#elif defined (__linux__)
9549767b 315extern void *__gnat_lwp_self (void);
6b81741c
AC
316
317/* Routines for interface to required CPU set primitives */
318
319#include <sched.h>
320
9d1e0e72
JR
321extern cpu_set_t *__gnat_cpu_alloc (size_t);
322extern size_t __gnat_cpu_alloc_size (size_t);
9f55bc62 323extern void __gnat_cpu_free (cpu_set_t *);
9d1e0e72
JR
324extern void __gnat_cpu_zero (size_t, cpu_set_t *);
325extern void __gnat_cpu_set (int, size_t, cpu_set_t *);
9549767b 326#endif
d7598e11 327
75069667
VF
328#if defined (_WIN32)
329/* Interface to delete a handle from internally maintained list of child
330 process handles on Windows */
6c802906 331extern int
75069667 332__gnat_win32_remove_handle (HANDLE h, int pid);
fbf5a39b 333#endif
437026ef 334
d23b8f57
RK
335#ifdef IN_RTS
336/* Portable definition of strdup, which is not available on all systems. */
337#define xstrdup(S) strcpy ((char *) malloc (strlen (S) + 1), S)
338#endif
fbf5a39b
AC
339
340/* This function returns the version of GCC being used. Here it's GCC 3. */
d7598e11 341extern int get_gcc_version (void);
fbf5a39b 342
d7598e11
PO
343extern int __gnat_binder_supports_auto_init (void);
344extern int __gnat_sals_init_using_constructors (void);
9e9bd455 345
747412b8
AC
346extern const void * __gnat_get_executable_load_address (void);
347
9e9bd455
LG
348#ifdef __cplusplus
349}
350#endif