OSDN Git Service

2009-04-08 Thomas Quinot <quinot@adacore.com>
[pf3gnuchains/gcc-fork.git] / gcc / ada / s-crtl.ads
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-2008, 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 2,  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.  See the GNU General Public License --
17 -- for  more details.  You should have  received  a copy of the GNU General --
18 -- Public License  distributed with GNAT;  see file COPYING.  If not, write --
19 -- to  the  Free Software Foundation,  51  Franklin  Street,  Fifth  Floor, --
20 -- Boston, MA 02110-1301, USA.                                              --
21 --                                                                          --
22 -- As a special exception,  if other files  instantiate  generics from this --
23 -- unit, or you link  this unit with other files  to produce an executable, --
24 -- this  unit  does not  by itself cause  the resulting  executable  to  be --
25 -- covered  by the  GNU  General  Public  License.  This exception does not --
26 -- however invalidate  any other reasons why  the executable file  might be --
27 -- covered by the  GNU Public License.                                      --
28 --                                                                          --
29 -- GNAT was originally developed  by the GNAT team at  New York University. --
30 -- Extensive contributions were provided by Ada Core Technologies Inc.      --
31 --                                                                          --
32 ------------------------------------------------------------------------------
33
34 --  This package provides the low level interface to the C Run Time Library
35 --  on non-VMS systems.
36
37 with System.Parameters;
38
39 package System.CRTL is
40    pragma Preelaborate;
41
42    subtype chars is System.Address;
43    --  Pointer to null-terminated array of characters
44
45    subtype DIRs is System.Address;
46    --  Corresponds to the C type DIR*
47
48    subtype FILEs is System.Address;
49    --  Corresponds to the C type FILE*
50
51    subtype int is Integer;
52
53    type long is range -(2 ** (System.Parameters.long_bits - 1))
54       .. +(2 ** (System.Parameters.long_bits - 1)) - 1;
55
56    subtype off_t is Long_Integer;
57
58    type size_t is mod 2 ** Standard'Address_Size;
59
60    type Filename_Encoding is (UTF8, ASCII_8bits);
61    for Filename_Encoding use (UTF8 => 0, ASCII_8bits => 1);
62    pragma Convention (C, Filename_Encoding);
63    --  Describes the filename's encoding
64
65    function atoi (A : System.Address) return Integer;
66    pragma Import (C, atoi, "atoi");
67
68    procedure clearerr (stream : FILEs);
69    pragma Import (C, clearerr, "clearerr");
70
71    function dup  (handle : int) return int;
72    pragma Import (C, dup, "dup");
73
74    function dup2 (from, to : int) return int;
75    pragma Import (C, dup2, "dup2");
76
77    function fclose (stream : FILEs) return int;
78    pragma Import (C, fclose, "fclose");
79
80    function fdopen (handle : int; mode : chars) return FILEs;
81    pragma Import (C, fdopen, "fdopen");
82
83    function fflush (stream : FILEs) return int;
84    pragma Import (C, fflush, "fflush");
85
86    function fgetc (stream : FILEs) return int;
87    pragma Import (C, fgetc, "fgetc");
88
89    function fgets (strng : chars; n : int; stream : FILEs) return chars;
90    pragma Import (C, fgets, "fgets");
91
92    function fopen
93      (filename : chars;
94       mode     : chars;
95       encoding : Filename_Encoding := UTF8) return FILEs;
96    pragma Import (C, fopen, "__gnat_fopen");
97
98    function fputc (C : int; stream : FILEs) return int;
99    pragma Import (C, fputc, "fputc");
100
101    function fputs (Strng : chars; Stream : FILEs) return int;
102    pragma Import (C, fputs, "fputs");
103
104    procedure free (Ptr : System.Address);
105    pragma Import (C, free, "free");
106
107    function freopen
108      (filename : chars;
109       mode     : chars;
110       stream   : FILEs;
111       encoding : Filename_Encoding := UTF8) return FILEs;
112    pragma Import (C, freopen, "__gnat_freopen");
113
114    function fseek
115      (stream : FILEs;
116       offset : long;
117       origin : int)
118       return   int;
119    pragma Import (C, fseek, "fseek");
120
121    function ftell (stream : FILEs) return long;
122    pragma Import (C, ftell, "ftell");
123
124    function getenv (S : String) return System.Address;
125    pragma Import (C, getenv, "getenv");
126
127    function isatty (handle : int) return int;
128    pragma Import (C, isatty, "isatty");
129
130    function lseek (fd : int; offset : off_t; direction : int) return off_t;
131    pragma Import (C, lseek, "lseek");
132
133    function malloc (Size : size_t) return System.Address;
134    pragma Import (C, malloc, "malloc");
135
136    function malloc32 (Size : size_t) return System.Address;
137    pragma Import (C, malloc32, "malloc");
138    --  An uncalled alias for malloc except on 64bit systems needing to
139    --  allocate 32bit memory.
140
141    procedure memcpy (S1 : System.Address; S2 : System.Address; N : size_t);
142    pragma Import (C, memcpy, "memcpy");
143
144    procedure memmove (S1 : System.Address; S2 : System.Address; N : size_t);
145    pragma Import (C, memmove, "memmove");
146
147    procedure mktemp (template : chars);
148    pragma Import (C, mktemp, "mktemp");
149
150    function pclose (stream : System.Address) return int;
151    pragma Import (C, pclose, "pclose");
152
153    function popen (command, mode : System.Address) return System.Address;
154    pragma Import (C, popen, "popen");
155
156    function realloc
157      (Ptr : System.Address; Size : size_t) return System.Address;
158    pragma Import (C, realloc, "realloc");
159
160    function realloc32
161      (Ptr : System.Address; Size : size_t) return System.Address;
162    pragma Import (C, realloc32, "realloc");
163    --  An uncalled alias for realloc except on 64bit systems needing to
164    --  allocate 32bit memory.
165
166    procedure rewind (stream : FILEs);
167    pragma Import (C, rewind, "rewind");
168
169    procedure rmdir (dir_name : String);
170    pragma Import (C, rmdir, "rmdir");
171
172    function setvbuf
173      (stream : FILEs;
174       buffer : chars;
175       mode   : int;
176       size   : size_t)
177       return   int;
178    pragma Import (C, setvbuf, "setvbuf");
179
180    procedure tmpnam (string : chars);
181    pragma Import (C, tmpnam, "tmpnam");
182
183    function tmpfile return FILEs;
184    pragma Import (C, tmpfile, "tmpfile");
185
186    function ungetc (c : int; stream : FILEs) return int;
187    pragma Import (C, ungetc, "ungetc");
188
189    function unlink (filename : chars) return int;
190    pragma Import (C, unlink, "unlink");
191
192    function open (filename : chars; oflag : int) return int;
193    pragma Import (C, open, "open");
194
195    function close (fd : int) return int;
196    pragma Import (C, close, "close");
197
198    function read (fd : int; buffer : chars; nbytes : int) return int;
199    pragma Import (C, read, "read");
200
201    function write (fd : int; buffer : chars; nbytes : int) return int;
202    pragma Import (C, write, "write");
203
204 end System.CRTL;