cfgexpand: Expand comment on when non-var clobbers can show up
[official-gcc.git] / gcc / ada / libgnat / s-crtl.ads
blob5c265e9a50327dcd5e483521960c6f131f761d37
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT RUN-TIME COMPONENTS --
4 -- --
5 -- S Y S T E M . C R T L --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 2003-2024, 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 -- This package provides the low level interface to the C runtime library
34 with System.Parameters;
36 package System.CRTL is
37 pragma Preelaborate;
39 subtype chars is System.Address;
40 -- Pointer to null-terminated array of characters
41 -- Should use Interfaces.C.Strings types instead, but this causes bootstrap
42 -- issues as i-c contains Ada 2005 specific features, not compatible with
43 -- older, Ada 95-only base compilers???
45 subtype DIRs is System.Address;
46 -- Corresponds to the C type DIR*
48 subtype FILEs is System.Address;
49 -- Corresponds to the C type FILE*
51 subtype int is Integer;
53 type long is range -(2 ** (System.Parameters.long_bits - 1))
54 .. +(2 ** (System.Parameters.long_bits - 1)) - 1;
56 subtype off_t is Long_Integer;
58 type size_t is mod System.Memory_Size;
60 type ssize_t is range -Memory_Size / 2 .. Memory_Size / 2 - 1;
62 type int64 is new Long_Long_Integer;
63 -- Note: we use Long_Long_Integer'First instead of -2 ** 63 to allow this
64 -- unit to compile when using custom target configuration files where the
65 -- maximum integer is 32 bits. This is useful for static analysis tools
66 -- such as SPARK or CodePeer. In the normal case, Long_Long_Integer is
67 -- always 64-bits so there is no difference.
69 type Filename_Encoding is (UTF8, ASCII_8bits, Unspecified);
70 for Filename_Encoding use (UTF8 => 0, ASCII_8bits => 1, Unspecified => 2);
71 pragma Convention (C, Filename_Encoding);
72 -- Describes the filename's encoding
74 --------------------
75 -- GCC intrinsics --
76 --------------------
78 -- The following functions are imported with convention Intrinsic so that
79 -- we take advantage of back-end builtins if present (else we fall back
80 -- to C library functions by the same names).
82 function strlen (A : System.Address) return size_t;
83 pragma Import (Intrinsic, strlen, "strlen");
85 procedure strncpy (dest, src : System.Address; n : size_t);
86 pragma Import (Intrinsic, strncpy, "strncpy");
88 -------------------------------
89 -- Other C runtime functions --
90 -------------------------------
92 function atoi (A : System.Address) return Integer;
93 pragma Import (C, atoi, "atoi");
95 procedure clearerr (stream : FILEs);
96 pragma Import (C, clearerr, "clearerr");
98 function dup (handle : int) return int;
99 pragma Import (C, dup, "dup");
101 function dup2 (from, to : int) return int;
102 pragma Import (C, dup2, "dup2");
104 function fclose (stream : FILEs) return int;
105 pragma Import (C, fclose, "fclose");
107 function fdopen (handle : int; mode : chars) return FILEs;
108 pragma Import (C, fdopen, "fdopen");
110 function fflush (stream : FILEs) return int;
111 pragma Import (C, fflush, "fflush");
113 function fgetc (stream : FILEs) return int;
114 pragma Import (C, fgetc, "fgetc");
116 function fgets (strng : chars; n : int; stream : FILEs) return chars;
117 pragma Import (C, fgets, "fgets");
119 function fopen
120 (filename : chars;
121 mode : chars;
122 encoding : Filename_Encoding := Unspecified) return FILEs;
123 pragma Import (C, fopen, "__gnat_fopen");
125 function fputc (C : int; stream : FILEs) return int;
126 pragma Import (C, fputc, "fputc");
128 function fputwc (C : int; stream : FILEs) return int;
129 pragma Import (C, fputwc, "__gnat_fputwc");
131 function fputs (Strng : chars; Stream : FILEs) return int;
132 pragma Import (C, fputs, "fputs");
134 procedure free (Ptr : System.Address);
135 pragma Import (C, free, "free");
137 function freopen
138 (filename : chars;
139 mode : chars;
140 stream : FILEs;
141 encoding : Filename_Encoding := Unspecified) return FILEs;
142 pragma Import (C, freopen, "__gnat_freopen");
144 function fseek
145 (stream : FILEs;
146 offset : long;
147 origin : int) return int;
148 pragma Import (C, fseek, "fseek");
150 function fseek64
151 (stream : FILEs;
152 offset : int64;
153 origin : int) return int;
154 pragma Import (C, fseek64, "__gnat_fseek64");
156 function ftell (stream : FILEs) return long;
157 pragma Import (C, ftell, "ftell");
159 function ftell64 (stream : FILEs) return int64;
160 pragma Import (C, ftell64, "__gnat_ftell64");
162 function getenv (S : String) return System.Address;
163 pragma Import (C, getenv, "getenv");
165 function isatty (handle : int) return int;
166 pragma Import (C, isatty, "isatty");
168 function lseek (fd : int; offset : off_t; direction : int) return off_t;
169 pragma Import (C, lseek, "lseek");
171 function malloc (Size : size_t) return System.Address;
172 pragma Import (C, malloc, "malloc");
174 procedure memcpy (S1 : System.Address; S2 : System.Address; N : size_t);
175 pragma Import (C, memcpy, "memcpy");
177 procedure memmove (S1 : System.Address; S2 : System.Address; N : size_t);
178 pragma Import (C, memmove, "memmove");
180 procedure mktemp (template : chars);
181 pragma Import (C, mktemp, "mktemp");
183 function pclose (stream : System.Address) return int;
184 pragma Import (C, pclose, "pclose");
186 function popen (command, mode : System.Address) return System.Address;
187 pragma Import (C, popen, "popen");
189 function realloc
190 (Ptr : System.Address; Size : size_t) return System.Address;
191 pragma Import (C, realloc, "realloc");
193 procedure rewind (stream : FILEs);
194 pragma Import (C, rewind, "rewind");
196 function rmdir (dir_name : String) return int;
197 pragma Import (C, rmdir, "__gnat_rmdir");
199 function chdir (dir_name : String) return int;
200 pragma Import (C, chdir, "__gnat_chdir");
202 function mkdir
203 (dir_name : String;
204 encoding : Filename_Encoding := Unspecified) return int;
205 pragma Import (C, mkdir, "__gnat_mkdir");
207 function setvbuf
208 (stream : FILEs;
209 buffer : chars;
210 mode : int;
211 size : size_t) return int;
212 pragma Import (C, setvbuf, "setvbuf");
214 procedure tmpnam (str : chars);
215 pragma Import (C, tmpnam, "tmpnam");
217 function tmpfile return FILEs;
218 pragma Import (C, tmpfile, "tmpfile");
220 function ungetc (c : int; stream : FILEs) return int;
221 pragma Import (C, ungetc, "ungetc");
223 function unlink (filename : chars;
224 encoding : Filename_Encoding := Unspecified) return int;
225 pragma Import (C, unlink, "__gnat_unlink");
227 function open (filename : chars; oflag : int) return int;
228 pragma Import (C, open, "__gnat_open");
230 function close (fd : int) return int;
231 pragma Import (C, close, "close");
233 function read (fd : int; buffer : chars; count : size_t) return ssize_t;
234 pragma Import (C, read, "read");
236 function write (fd : int; buffer : chars; count : size_t) return ssize_t;
237 pragma Import (C, write, "write");
239 end System.CRTL;