PR rtl-optimization/57003
[official-gcc.git] / gcc / ada / adaint.h
blobd2a838e53f5476d1ddaa26d5f155fd186ddc002a
1 /****************************************************************************
2 * *
3 * GNAT COMPILER COMPONENTS *
4 * *
5 * A D A I N T *
6 * *
7 * C Header File *
8 * *
9 * Copyright (C) 1992-2014, 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 #ifdef _WIN32
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 (sun)
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 #else
71 #define GNAT_FOPEN fopen
72 #define GNAT_OPEN open
73 #define GNAT_STAT stat
74 #define GNAT_FSTAT fstat
75 #define GNAT_LSTAT lstat
76 #define GNAT_STRUCT_STAT struct stat
77 #endif
79 /* Type corresponding to GNAT.OS_Lib.OS_Time */
80 #if defined (_WIN64)
81 typedef long long OS_Time;
82 #else
83 typedef long OS_Time;
84 #endif
86 #define __int64 long long
88 /* A lazy cache for the attributes of a file. On some systems, a single call to
89 stat() will give all this information, so it is better than doing a system
90 call every time. On other systems this require several system calls.
93 struct file_attributes {
94 int error;
95 /* Errno value returned by stat()/fstat(). If non-zero, other fields should
96 * be considered as invalid.
99 unsigned char exists;
101 unsigned char writable;
102 unsigned char readable;
103 unsigned char executable;
105 unsigned char symbolic_link;
106 unsigned char regular;
107 unsigned char directory;
109 OS_Time timestamp;
110 __int64 file_length;
112 /* WARNING: changing the size here might require changing the constant
113 * File_Attributes_Size in osint.ads (which should be big enough to
114 * fit the above struct on any system)
117 extern int __gnat_max_path_len;
118 extern OS_Time __gnat_current_time (void);
119 extern void __gnat_current_time_string (char *);
120 extern void __gnat_to_gm_time (OS_Time *, int *, int *,
121 int *, int *,
122 int *, int *);
123 extern void __gnat_to_os_time (OS_Time *, int, int, int,
124 int, int, int);
125 extern int __gnat_get_maximum_file_name_length (void);
126 extern int __gnat_get_switches_case_sensitive (void);
127 extern int __gnat_get_file_names_case_sensitive (void);
128 extern int __gnat_get_env_vars_case_sensitive (void);
129 extern char __gnat_get_default_identifier_character_set (void);
130 extern void __gnat_get_current_dir (char *, int *);
131 extern void __gnat_get_object_suffix_ptr (int *,
132 const char **);
133 extern void __gnat_get_executable_suffix_ptr (int *,
134 const char **);
135 extern void __gnat_get_debuggable_suffix_ptr (int *,
136 const char **);
137 extern int __gnat_readlink (char *, char *,
138 size_t);
139 extern int __gnat_symlink (char *, char *);
140 extern int __gnat_try_lock (char *, char *);
141 extern int __gnat_open_new (char *, int);
142 extern int __gnat_open_new_temp (char *, int);
143 extern int __gnat_mkdir (char *, int);
144 extern int __gnat_stat (char *,
145 GNAT_STRUCT_STAT *);
146 extern int __gnat_unlink (char *);
147 extern int __gnat_rename (char *, char *);
148 extern int __gnat_chdir (char *);
149 extern int __gnat_rmdir (char *);
151 extern FILE *__gnat_fopen (char *, char *, int);
152 extern FILE *__gnat_freopen (char *, char *, FILE *,
153 int);
154 extern int __gnat_open (char *, int);
155 extern int __gnat_open_read (char *, int);
156 extern int __gnat_open_rw (char *, int);
157 extern int __gnat_open_create (char *, int);
158 extern int __gnat_create_output_file (char *);
159 extern int __gnat_create_output_file_new (char *);
161 extern int __gnat_open_append (char *, int);
162 extern long __gnat_file_length_long (int);
163 extern __int64 __gnat_file_length (int);
164 extern __int64 __gnat_named_file_length (char *);
165 extern void __gnat_tmp_name (char *);
166 extern DIR *__gnat_opendir (char *);
167 extern char *__gnat_readdir (DIR *, char *, int *);
168 extern int __gnat_closedir (DIR *);
169 extern int __gnat_readdir_is_thread_safe (void);
171 extern OS_Time __gnat_file_time_name (char *);
172 extern OS_Time __gnat_file_time_fd (int);
173 /* return -1 in case of error */
175 extern void __gnat_set_file_time_name (char *, time_t);
177 extern int __gnat_dup (int);
178 extern int __gnat_dup2 (int, int);
179 extern int __gnat_file_exists (char *);
180 extern int __gnat_is_regular_file (char *);
181 extern int __gnat_is_absolute_path (char *,int);
182 extern int __gnat_is_directory (char *);
183 extern int __gnat_is_writable_file (char *);
184 extern int __gnat_is_readable_file (char *name);
185 extern int __gnat_is_executable_file (char *name);
187 extern void __gnat_reset_attributes (struct file_attributes *);
188 extern int __gnat_error_attributes (struct file_attributes *);
189 extern __int64 __gnat_file_length_attr (int, char *, struct file_attributes *);
190 extern OS_Time __gnat_file_time_name_attr (char *, struct file_attributes *);
191 extern OS_Time __gnat_file_time_fd_attr (int, struct file_attributes *);
192 extern int __gnat_file_exists_attr (char *, struct file_attributes *);
193 extern int __gnat_is_regular_file_attr (char *, struct file_attributes *);
194 extern int __gnat_is_directory_attr (char *, struct file_attributes *);
195 extern int __gnat_is_readable_file_attr (char *, struct file_attributes *);
196 extern int __gnat_is_writable_file_attr (char *, struct file_attributes *);
197 extern int __gnat_is_executable_file_attr (char *, struct file_attributes *);
198 extern int __gnat_is_symbolic_link_attr (char *, struct file_attributes *);
200 extern void __gnat_set_non_writable (char *name);
201 extern void __gnat_set_writable (char *name);
202 extern void __gnat_set_executable (char *name, int);
203 extern void __gnat_set_readable (char *name);
204 extern void __gnat_set_non_readable (char *name);
205 extern int __gnat_is_symbolic_link (char *name);
206 extern int __gnat_portable_spawn (char *[]);
207 extern int __gnat_portable_no_block_spawn (char *[]);
208 extern int __gnat_portable_wait (int *);
209 extern char *__gnat_locate_exec (char *, char *);
210 extern char *__gnat_locate_exec_on_path (char *);
211 extern char *__gnat_locate_regular_file (char *, char *);
212 extern void __gnat_maybe_glob_args (int *, char ***);
213 extern void __gnat_os_exit (int);
214 extern char *__gnat_get_libraries_from_registry (void);
215 extern int __gnat_to_canonical_file_list_init (char *, int);
216 extern char *__gnat_to_canonical_file_list_next (void);
217 extern void __gnat_to_canonical_file_list_free (void);
218 extern char *__gnat_to_canonical_dir_spec (char *, int);
219 extern char *__gnat_to_canonical_file_spec (char *);
220 extern char *__gnat_to_host_dir_spec (char *, int);
221 extern char *__gnat_to_host_file_spec (char *);
222 extern char *__gnat_to_canonical_path_spec (char *);
223 extern void __gnat_adjust_os_resource_limits (void);
224 extern void convert_addresses (const char *, void *, int,
225 void *, int *);
226 extern int __gnat_copy_attribs (char *, char *, int);
227 extern int __gnat_feof (FILE *);
228 extern int __gnat_ferror (FILE *);
229 extern int __gnat_fileno (FILE *);
230 extern int __gnat_is_regular_file_fd (int);
231 extern FILE *__gnat_constant_stderr (void);
232 extern FILE *__gnat_constant_stdin (void);
233 extern FILE *__gnat_constant_stdout (void);
234 extern char *__gnat_full_name (char *, char *);
236 extern int __gnat_arg_count (void);
237 extern int __gnat_len_arg (int);
238 extern void __gnat_fill_arg (char *, int);
239 extern int __gnat_env_count (void);
240 extern int __gnat_len_env (int);
241 extern void __gnat_fill_env (char *, int);
243 /* Routines for interface to scanf and printf functions for integer values */
245 extern int get_int (void);
246 extern void put_int (int);
247 extern void put_int_stderr (int);
248 extern int get_char (void);
249 extern void put_char (int);
250 extern void put_char_stderr (int);
251 extern char *mktemp (char *);
253 extern void __gnat_set_exit_status (int);
255 extern int __gnat_expect_fork (void);
256 extern void __gnat_expect_portable_execvp (char *, char *[]);
257 extern int __gnat_pipe (int *);
258 extern int __gnat_expect_poll (int *, int, int, int *);
259 extern void __gnat_set_binary_mode (int);
260 extern void __gnat_set_text_mode (int);
261 extern void __gnat_set_mode (int,int);
262 extern char *__gnat_ttyname (int);
263 extern int __gnat_lseek (int, long, int);
264 extern int __gnat_set_close_on_exec (int, int);
265 extern int __gnat_dup (int);
266 extern int __gnat_dup2 (int, int);
268 /* large file support */
269 extern __int64 __gnat_ftell64 (FILE *);
270 extern int __gnat_fseek64 (FILE *, __int64, int);
272 extern int __gnat_number_of_cpus (void);
274 extern void __gnat_os_filename (char *, char *, char *,
275 int *, char *, int *);
277 extern char * __gnat_locate_executable_file (char *, char *);
278 extern char * __gnat_locate_file_with_predicate (char *, char *,
279 int (*)(char*));
281 #if defined (__ANDROID__)
282 #undef linux
283 extern void *__gnat_lwp_self (void);
285 #elif defined (linux)
286 extern void *__gnat_lwp_self (void);
288 /* Routines for interface to required CPU set primitives */
290 #include <sched.h>
292 extern cpu_set_t *__gnat_cpu_alloc (size_t);
293 extern size_t __gnat_cpu_alloc_size (size_t);
294 extern void __gnat_cpu_free (cpu_set_t *);
295 extern void __gnat_cpu_zero (size_t, cpu_set_t *);
296 extern void __gnat_cpu_set (int, size_t, cpu_set_t *);
297 #endif
299 #if defined (_WIN32)
300 /* Interface to delete a handle from internally maintained list of child
301 process handles on Windows */
302 extern void
303 __gnat_win32_remove_handle (HANDLE h, int pid);
304 #endif
306 #ifdef IN_RTS
307 /* Portable definition of strdup, which is not available on all systems. */
308 #define xstrdup(S) strcpy ((char *) malloc (strlen (S) + 1), S)
309 #endif
311 /* This function returns the version of GCC being used. Here it's GCC 3. */
312 extern int get_gcc_version (void);
314 extern int __gnat_binder_supports_auto_init (void);
315 extern int __gnat_sals_init_using_constructors (void);
317 extern const void * __gnat_get_executable_load_address (void);
319 #ifdef __cplusplus
321 #endif