Avoid no-stack-protector-attr fails on hppa*-*-*.
[official-gcc.git] / gcc / ada / adaint.h
blob85997b9ba6858e22da8897e96ca48ec702b93aec
1 /****************************************************************************
2 * *
3 * GNAT COMPILER COMPONENTS *
4 * *
5 * A D A I N T *
6 * *
7 * C Header File *
8 * *
9 * Copyright (C) 1992-2020, Free Software Foundation, Inc. *
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- *
13 * ware Foundation; either version 3, or (at your option) any later ver- *
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 *
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/>. *
26 * *
27 * GNAT was originally developed by the GNAT team at New York University. *
28 * Extensive contributions were provided by Ada Core Technologies Inc. *
29 * *
30 ****************************************************************************/
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
36 #include <sys/stat.h>
37 #include <stdio.h>
39 #if defined (_WIN32) || defined (__CYGWIN__)
40 #include "mingw32.h"
41 #endif
43 #include <dirent.h>
45 /* Constants used for the form parameter encoding values */
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. */
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. */
54 #if (defined (__GLIBC__) && !defined(STANDALONE)) || defined (__sun__) || defined (__QNX__)
55 #define GNAT_FOPEN fopen64
56 #define GNAT_OPEN open64
57 #define GNAT_STAT stat64
58 #define GNAT_FSTAT fstat64
59 #define GNAT_LSTAT lstat64
60 #define GNAT_STRUCT_STAT struct stat64
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
70 #elif defined(__APPLE__)
72 # include <TargetConditionals.h>
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
90 # define GNAT_FOPEN fopen
91 # define GNAT_OPEN open
92 # define GNAT_STRUCT_STAT struct stat
94 #else
95 #define GNAT_FOPEN fopen
96 #define GNAT_OPEN open
97 #define GNAT_STAT stat
98 #define GNAT_FSTAT fstat
99 #define GNAT_LSTAT lstat
100 #define GNAT_STRUCT_STAT struct stat
101 #endif
103 /* Type corresponding to GNAT.OS_Lib.OS_Time */
104 #if defined (_WIN64)
105 typedef long long OS_Time;
106 #else
107 typedef long OS_Time;
108 #endif
110 #define __int64 long long
111 GNAT_STRUCT_STAT;
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.
118 struct file_attributes {
119 int error;
120 /* Errno value returned by stat()/fstat(). If non-zero, other fields should
121 * be considered as invalid.
124 unsigned char exists;
126 unsigned char writable;
127 unsigned char readable;
128 unsigned char executable;
130 unsigned char symbolic_link;
131 unsigned char regular;
132 unsigned char directory;
134 OS_Time timestamp;
135 __int64 file_length;
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)
142 extern int __gnat_max_path_len;
143 extern int __gnat_in_child_after_fork;
144 /* This flag expresses the state when the fork call just returned zero result,
145 * i.e. when the new born child process is created and the new executable is
146 * not loaded yet. It is used to e.g. disable tracing memory
147 * allocation/deallocation in memtrack.adb just after fork returns in the child
148 * process to avoid both parent and child writing to the same gmem.out file
149 * simultaneously */
151 extern OS_Time __gnat_current_time (void);
152 extern void __gnat_current_time_string (char *);
153 extern void __gnat_to_gm_time (OS_Time *, int *, int *,
154 int *, int *,
155 int *, int *);
156 extern void __gnat_to_os_time (OS_Time *, int, int, int,
157 int, int, int);
158 extern int __gnat_get_maximum_file_name_length (void);
159 extern int __gnat_get_switches_case_sensitive (void);
160 extern int __gnat_get_file_names_case_sensitive (void);
161 extern int __gnat_get_env_vars_case_sensitive (void);
162 extern char __gnat_get_default_identifier_character_set (void);
163 extern void __gnat_get_current_dir (char *, int *);
164 extern void __gnat_get_object_suffix_ptr (int *,
165 const char **);
166 extern void __gnat_get_executable_suffix_ptr (int *,
167 const char **);
168 extern void __gnat_get_debuggable_suffix_ptr (int *,
169 const char **);
170 extern int __gnat_readlink (char *, char *,
171 size_t);
172 extern int __gnat_symlink (char *, char *);
173 extern int __gnat_try_lock (char *, char *);
174 extern int __gnat_open_new (char *, int);
175 extern int __gnat_open_new_temp (char *, int);
176 extern int __gnat_mkdir (char *, int);
177 extern int __gnat_stat (char *,
178 GNAT_STRUCT_STAT *);
179 extern int __gnat_unlink (char *);
180 extern int __gnat_rename (char *, char *);
181 extern int __gnat_chdir (char *);
182 extern int __gnat_rmdir (char *);
184 extern FILE *__gnat_fopen (char *, char *, int);
185 extern FILE *__gnat_freopen (char *, char *, FILE *,
186 int);
187 extern int __gnat_open (char *, int);
188 extern int __gnat_open_read (char *, int);
189 extern int __gnat_open_rw (char *, int);
190 extern int __gnat_open_create (char *, int);
191 extern int __gnat_create_output_file (char *);
192 extern int __gnat_create_output_file_new (char *);
194 extern int __gnat_open_append (char *, int);
195 extern long __gnat_file_length_long (int);
196 extern __int64 __gnat_file_length (int);
197 extern __int64 __gnat_named_file_length (char *);
198 extern void __gnat_tmp_name (char *);
199 extern DIR *__gnat_opendir (char *);
200 extern char *__gnat_readdir (DIR *, char *, int *);
201 extern int __gnat_closedir (DIR *);
202 extern int __gnat_readdir_is_thread_safe (void);
204 extern OS_Time __gnat_file_time_name (char *);
205 extern OS_Time __gnat_file_time_fd (int);
206 /* return -1 in case of error */
208 extern void __gnat_set_file_time_name (char *, time_t);
210 extern int __gnat_dup (int);
211 extern int __gnat_dup2 (int, int);
212 extern int __gnat_file_exists (char *);
213 extern int __gnat_is_regular_file (char *);
214 extern int __gnat_is_absolute_path (char *,int);
215 extern int __gnat_is_directory (char *);
216 extern int __gnat_is_writable_file (char *);
217 extern int __gnat_is_readable_file (char *name);
218 extern int __gnat_is_executable_file (char *name);
219 extern int __gnat_is_write_accessible_file (char *name);
220 extern int __gnat_is_read_accessible_file (char *name);
222 extern void __gnat_reset_attributes (struct file_attributes *);
223 extern int __gnat_error_attributes (struct file_attributes *);
224 extern __int64 __gnat_file_length_attr (int, char *, struct file_attributes *);
225 extern OS_Time __gnat_file_time_name_attr (char *, struct file_attributes *);
226 extern OS_Time __gnat_file_time_fd_attr (int, struct file_attributes *);
227 extern int __gnat_file_exists_attr (char *, struct file_attributes *);
228 extern int __gnat_is_regular_file_attr (char *, struct file_attributes *);
229 extern int __gnat_is_directory_attr (char *, struct file_attributes *);
230 extern int __gnat_is_readable_file_attr (char *, struct file_attributes *);
231 extern int __gnat_is_writable_file_attr (char *, struct file_attributes *);
232 extern int __gnat_is_executable_file_attr (char *, struct file_attributes *);
233 extern int __gnat_is_symbolic_link_attr (char *, struct file_attributes *);
235 extern void __gnat_set_non_writable (char *name);
236 extern void __gnat_set_writable (char *name);
237 extern void __gnat_set_executable (char *name, int);
238 extern void __gnat_set_readable (char *name);
239 extern void __gnat_set_non_readable (char *name);
240 extern int __gnat_is_symbolic_link (char *name);
241 extern int __gnat_portable_spawn (char *[]);
242 extern int __gnat_portable_no_block_spawn (char *[]);
243 extern int __gnat_portable_wait (int *);
244 extern int __gnat_portable_no_block_wait (int *);
245 extern int __gnat_current_process_id (void);
246 extern char *__gnat_locate_exec (char *, char *);
247 extern char *__gnat_locate_exec_on_path (char *);
248 extern char *__gnat_locate_regular_file (char *, char *);
249 extern void __gnat_maybe_glob_args (int *, char ***);
250 extern void __gnat_os_exit (int);
251 extern char *__gnat_get_libraries_from_registry (void);
252 extern int __gnat_to_canonical_file_list_init (char *, int);
253 extern char *__gnat_to_canonical_file_list_next (void);
254 extern void __gnat_to_canonical_file_list_free (void);
255 extern char *__gnat_to_canonical_dir_spec (char *, int);
256 extern char *__gnat_to_canonical_file_spec (char *);
257 extern char *__gnat_to_host_dir_spec (char *, int);
258 extern char *__gnat_to_host_file_spec (char *);
259 extern char *__gnat_to_canonical_path_spec (char *);
260 extern void __gnat_adjust_os_resource_limits (void);
261 extern void convert_addresses (const char *, void *, int,
262 void *, int *);
263 extern int __gnat_copy_attribs (char *, char *, int);
264 extern int __gnat_feof (FILE *);
265 extern int __gnat_ferror (FILE *);
266 extern int __gnat_fileno (FILE *);
267 extern int __gnat_is_regular_file_fd (int);
268 extern FILE *__gnat_constant_stderr (void);
269 extern FILE *__gnat_constant_stdin (void);
270 extern FILE *__gnat_constant_stdout (void);
271 extern char *__gnat_full_name (char *, char *);
273 extern int __gnat_arg_count (void);
274 extern int __gnat_len_arg (int);
275 extern void __gnat_fill_arg (char *, int);
276 extern int __gnat_env_count (void);
277 extern int __gnat_len_env (int);
278 extern void __gnat_fill_env (char *, int);
280 /* Routines for interface to scanf and printf functions for integer values */
282 extern int get_int (void);
283 extern void put_int (int);
284 extern void put_int_stderr (int);
285 extern int get_char (void);
286 extern void put_char (int);
287 extern void put_char_stderr (int);
288 extern char *mktemp (char *);
290 extern void __gnat_set_exit_status (int);
292 extern int __gnat_expect_fork (void);
293 extern void __gnat_expect_portable_execvp (int *, char *, char *[]);
294 extern int __gnat_pipe (int *);
295 extern int __gnat_expect_poll (int *, int, int, int *,
296 int *);
297 extern void __gnat_set_binary_mode (int);
298 extern void __gnat_set_text_mode (int);
299 extern void __gnat_set_mode (int,int);
300 extern char *__gnat_ttyname (int);
301 extern int __gnat_lseek (int, long, int);
302 extern int __gnat_set_close_on_exec (int, int);
303 extern int __gnat_dup (int);
304 extern int __gnat_dup2 (int, int);
306 /* large file support */
307 extern __int64 __gnat_ftell64 (FILE *);
308 extern int __gnat_fseek64 (FILE *, __int64, int);
310 extern int __gnat_number_of_cpus (void);
312 extern void __gnat_os_filename (char *, char *, char *,
313 int *, char *, int *);
315 extern char * __gnat_locate_executable_file (char *, char *);
316 extern char * __gnat_locate_file_with_predicate (char *, char *,
317 int (*)(char*));
319 #if defined (__ANDROID__)
320 #undef __linux__
321 extern void *__gnat_lwp_self (void);
323 #elif defined (__linux__)
324 extern void *__gnat_lwp_self (void);
326 /* Routines for interface to required CPU set primitives */
328 #include <sched.h>
330 extern cpu_set_t *__gnat_cpu_alloc (size_t);
331 extern size_t __gnat_cpu_alloc_size (size_t);
332 extern void __gnat_cpu_free (cpu_set_t *);
333 extern void __gnat_cpu_zero (size_t, cpu_set_t *);
334 extern void __gnat_cpu_set (int, size_t, cpu_set_t *);
335 #endif
337 #if defined (_WIN32)
338 /* Interface to delete a handle from internally maintained list of child
339 process handles on Windows */
340 extern int
341 __gnat_win32_remove_handle (HANDLE h, int pid);
342 #endif
344 #ifdef IN_RTS
345 /* Portable definition of strdup, which is not available on all systems. */
346 #define xstrdup(S) strcpy ((char *) malloc (strlen (S) + 1), S)
347 #endif
349 /* This function returns the version of GCC being used. Here it's GCC 3. */
350 extern int get_gcc_version (void);
352 extern int __gnat_binder_supports_auto_init (void);
353 extern int __gnat_sals_init_using_constructors (void);
355 extern const void * __gnat_get_executable_load_address (void);
357 #ifdef __cplusplus
359 #endif