PR c++/43856
[official-gcc/constexpr.git] / gcc / ada / adaint.h
blob7af079e35a961510d071f9e367c09278bfefecb0
1 /****************************************************************************
2 * *
3 * GNAT COMPILER COMPONENTS *
4 * *
5 * A D A I N T *
6 * *
7 * C Header File *
8 * *
9 * Copyright (C) 1992-2009, 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 #include <sys/stat.h>
33 #include <stdio.h>
35 #ifdef _WIN32
36 #include "mingw32.h"
37 #endif
39 #include <dirent.h>
41 /* Constants used for the form parameter encoding values */
42 #define Encoding_UTF8 0 /* UTF-8 */
43 #define Encoding_8bits 1 /* Standard 8bits, CP_ACP on Windows. */
44 #define Encoding_Unspecified 2 /* Based on GNAT_CODE_PAGE env variable. */
46 /* Large file support. It is unclear what portable mechanism we can use to
47 determine at compile time what support the system offers for large files.
48 For now we just list the platforms we have manually tested. */
50 #if defined (__GLIBC__) || defined (sun) || (defined (__sgi) && defined(_LFAPI))
51 #define GNAT_FOPEN fopen64
52 #define GNAT_STAT stat64
53 #define GNAT_FSTAT fstat64
54 #define GNAT_LSTAT lstat64
55 #define GNAT_STRUCT_STAT struct stat64
56 #else
57 #define GNAT_FOPEN fopen
58 #define GNAT_STAT stat
59 #define GNAT_FSTAT fstat
60 #define GNAT_LSTAT lstat
61 #define GNAT_STRUCT_STAT struct stat
62 #endif
64 /* Type corresponding to GNAT.OS_Lib.OS_Time */
65 #if defined (_WIN64)
66 typedef long long OS_Time;
67 #else
68 typedef long OS_Time;
69 #endif
71 /* A lazy cache for the attributes of a file. On some systems, a single call to
72 stat() will give all this information, so it is better than doing a system
73 call every time. On other systems this require several system calls.
76 struct file_attributes {
77 unsigned char exists;
79 unsigned char writable;
80 unsigned char readable;
81 unsigned char executable;
83 unsigned char symbolic_link;
84 unsigned char regular;
85 unsigned char directory;
87 OS_Time timestamp;
88 long file_length;
90 /* WARNING: changing the size here might require changing the constant
91 * File_Attributes_Size in osint.ads (which should be big enough to
92 * fit the above struct on any system)
95 extern int __gnat_max_path_len;
96 extern OS_Time __gnat_current_time (void);
97 extern void __gnat_current_time_string (char *);
98 extern void __gnat_to_gm_time (OS_Time *, int *, int *,
99 int *, int *,
100 int *, int *);
101 extern int __gnat_get_maximum_file_name_length (void);
102 extern int __gnat_get_switches_case_sensitive (void);
103 extern int __gnat_get_file_names_case_sensitive (void);
104 extern char __gnat_get_default_identifier_character_set (void);
105 extern void __gnat_get_current_dir (char *, int *);
106 extern void __gnat_get_object_suffix_ptr (int *,
107 const char **);
108 extern void __gnat_get_executable_suffix_ptr (int *,
109 const char **);
110 extern void __gnat_get_debuggable_suffix_ptr (int *,
111 const char **);
112 extern int __gnat_readlink (char *, char *,
113 size_t);
114 extern int __gnat_symlink (char *, char *);
115 extern int __gnat_try_lock (char *, char *);
116 extern int __gnat_open_new (char *, int);
117 extern int __gnat_open_new_temp (char *, int);
118 extern int __gnat_mkdir (char *);
119 extern int __gnat_stat (char *,
120 GNAT_STRUCT_STAT *);
121 extern int __gnat_unlink (char *);
122 extern int __gnat_rename (char *, char *);
123 extern int __gnat_chdir (char *);
124 extern int __gnat_rmdir (char *);
126 extern FILE *__gnat_fopen (char *, char *, int);
127 extern FILE *__gnat_freopen (char *, char *, FILE *,
128 int);
129 extern int __gnat_open_read (char *, int);
130 extern int __gnat_open_rw (char *, int);
131 extern int __gnat_open_create (char *, int);
132 extern int __gnat_create_output_file (char *);
133 extern int __gnat_open_append (char *, int);
134 extern long __gnat_file_length (int);
135 extern long __gnat_named_file_length (char *);
136 extern void __gnat_tmp_name (char *);
137 extern DIR *__gnat_opendir (char *);
138 extern char *__gnat_readdir (DIR *, char *, int *);
139 extern int __gnat_closedir (DIR *);
140 extern int __gnat_readdir_is_thread_safe (void);
142 extern OS_Time __gnat_file_time_name (char *);
143 extern OS_Time __gnat_file_time_fd (int);
144 /* return -1 in case of error */
146 extern void __gnat_set_file_time_name (char *, time_t);
148 extern int __gnat_dup (int);
149 extern int __gnat_dup2 (int, int);
150 extern int __gnat_file_exists (char *);
151 extern int __gnat_is_regular_file (char *);
152 extern int __gnat_is_absolute_path (char *,int);
153 extern int __gnat_is_directory (char *);
154 extern int __gnat_is_writable_file (char *);
155 extern int __gnat_is_readable_file (char *name);
156 extern int __gnat_is_executable_file (char *name);
158 extern void __gnat_reset_attributes (struct file_attributes* attr);
159 extern long __gnat_file_length_attr (int, char *, struct file_attributes *);
160 extern OS_Time __gnat_file_time_name_attr (char *, struct file_attributes *);
161 extern OS_Time __gnat_file_time_fd_attr (int, struct file_attributes *);
162 extern int __gnat_file_exists_attr (char *, struct file_attributes *);
163 extern int __gnat_is_regular_file_attr (char *, struct file_attributes *);
164 extern int __gnat_is_directory_attr (char *, struct file_attributes *);
165 extern int __gnat_is_readable_file_attr (char *, struct file_attributes *);
166 extern int __gnat_is_writable_file_attr (char *, struct file_attributes *);
167 extern int __gnat_is_executable_file_attr (char *, struct file_attributes *);
168 extern int __gnat_is_symbolic_link_attr (char *, struct file_attributes *);
170 extern void __gnat_set_non_writable (char *name);
171 extern void __gnat_set_writable (char *name);
172 extern void __gnat_set_executable (char *name);
173 extern void __gnat_set_readable (char *name);
174 extern void __gnat_set_non_readable (char *name);
175 extern int __gnat_is_symbolic_link (char *name);
176 extern int __gnat_portable_spawn (char *[]);
177 extern int __gnat_portable_no_block_spawn (char *[]);
178 extern int __gnat_portable_wait (int *);
179 extern char *__gnat_locate_exec (char *, char *);
180 extern char *__gnat_locate_exec_on_path (char *);
181 extern char *__gnat_locate_regular_file (char *, char *);
182 extern void __gnat_maybe_glob_args (int *, char ***);
183 extern void __gnat_os_exit (int);
184 extern char *__gnat_get_libraries_from_registry (void);
185 extern int __gnat_to_canonical_file_list_init (char *, int);
186 extern char *__gnat_to_canonical_file_list_next (void);
187 extern void __gnat_to_canonical_file_list_free (void);
188 extern char *__gnat_to_canonical_dir_spec (char *, int);
189 extern char *__gnat_to_canonical_file_spec (char *);
190 extern char *__gnat_to_host_dir_spec (char *, int);
191 extern char *__gnat_to_host_file_spec (char *);
192 extern char *__gnat_to_canonical_path_spec (char *);
193 extern void __gnat_adjust_os_resource_limits (void);
194 extern void convert_addresses (const char *, void *, int,
195 void *, int *);
196 extern int __gnat_copy_attribs (char *, char *, int);
197 extern int __gnat_feof (FILE *);
198 extern int __gnat_ferror (FILE *);
199 extern int __gnat_fileno (FILE *);
200 extern int __gnat_is_regular_file_fd (int);
201 extern FILE *__gnat_constant_stderr (void);
202 extern FILE *__gnat_constant_stdin (void);
203 extern FILE *__gnat_constant_stdout (void);
204 extern char *__gnat_full_name (char *, char *);
206 extern int __gnat_arg_count (void);
207 extern int __gnat_len_arg (int);
208 extern void __gnat_fill_arg (char *, int);
209 extern int __gnat_env_count (void);
210 extern int __gnat_len_env (int);
211 extern void __gnat_fill_env (char *, int);
213 /* Routines for interface to scanf and printf functions for integer values */
215 extern int get_int (void);
216 extern void put_int (int);
217 extern void put_int_stderr (int);
218 extern int get_char (void);
219 extern void put_char (int);
220 extern void put_char_stderr (int);
221 extern char *mktemp (char *);
223 extern void __gnat_set_exit_status (int);
225 extern int __gnat_expect_fork (void);
226 extern void __gnat_expect_portable_execvp (char *, char *[]);
227 extern int __gnat_pipe (int *);
228 extern int __gnat_expect_poll (int *, int, int, int *);
229 extern void __gnat_set_binary_mode (int);
230 extern void __gnat_set_text_mode (int);
231 extern char *__gnat_ttyname (int);
232 extern int __gnat_lseek (int, long, int);
233 extern int __gnat_set_close_on_exec (int, int);
234 extern int __gnat_dup (int);
235 extern int __gnat_dup2 (int, int);
237 extern void __gnat_os_filename (char *, char *, char *,
238 int *, char *, int *);
239 #if defined (linux)
240 extern void *__gnat_lwp_self (void);
241 #endif
243 #if defined (_WIN32)
244 /* Interface to delete a handle from internally maintained list of child
245 process handles on Windows */
246 extern void
247 __gnat_win32_remove_handle (HANDLE h, int pid);
248 #endif
250 #ifdef IN_RTS
251 /* Portable definition of strdup, which is not available on all systems. */
252 #define xstrdup(S) strcpy ((char *) malloc (strlen (S) + 1), S)
253 #endif
255 /* This function returns the version of GCC being used. Here it's GCC 3. */
256 extern int get_gcc_version (void);
258 extern int __gnat_binder_supports_auto_init (void);
259 extern int __gnat_sals_init_using_constructors (void);