OSDN Git Service

2009-11-30 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-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 ------------------------------------------------------------------------------
31
32 --  This package provides the low level interface to the C runtime library
33
34 with Interfaces.C.Strings;
35
36 with System.Parameters;
37
38 package System.CRTL is
39    pragma Preelaborate;
40
41    subtype chars_ptr is Interfaces.C.Strings.chars_ptr;
42
43    subtype chars is System.Address;
44    --  Pointer to null-terminated array of characters
45    --  Should use Interfaces.C.Strings types instead???
46
47    subtype DIRs is System.Address;
48    --  Corresponds to the C type DIR*
49
50    subtype FILEs is System.Address;
51    --  Corresponds to the C type FILE*
52
53    subtype int is Integer;
54
55    type long is range -(2 ** (System.Parameters.long_bits - 1))
56                    .. +(2 ** (System.Parameters.long_bits - 1)) - 1;
57
58    subtype off_t is Long_Integer;
59
60    type size_t is mod 2 ** Standard'Address_Size;
61
62    type Filename_Encoding is (UTF8, ASCII_8bits, Unspecified);
63    for Filename_Encoding use (UTF8 => 0, ASCII_8bits => 1, Unspecified => 2);
64    pragma Convention (C, Filename_Encoding);
65    --  Describes the filename's encoding
66
67    function atoi (A : System.Address) return Integer;
68    pragma Import (C, atoi, "atoi");
69
70    procedure clearerr (stream : FILEs);
71    pragma Import (C, clearerr, "clearerr");
72
73    function dup  (handle : int) return int;
74    pragma Import (C, dup, "dup");
75
76    function dup2 (from, to : int) return int;
77    pragma Import (C, dup2, "dup2");
78
79    function fclose (stream : FILEs) return int;
80    pragma Import (C, fclose, "fclose");
81
82    function fdopen (handle : int; mode : chars) return FILEs;
83    pragma Import (C, fdopen, "fdopen");
84
85    function fflush (stream : FILEs) return int;
86    pragma Import (C, fflush, "fflush");
87
88    function fgetc (stream : FILEs) return int;
89    pragma Import (C, fgetc, "fgetc");
90
91    function fgets (strng : chars; n : int; stream : FILEs) return chars;
92    pragma Import (C, fgets, "fgets");
93
94    function fopen
95      (filename : chars;
96       mode     : chars;
97       encoding : Filename_Encoding := Unspecified) return FILEs;
98    pragma Import (C, fopen, "__gnat_fopen");
99
100    function fputc (C : int; stream : FILEs) return int;
101    pragma Import (C, fputc, "fputc");
102
103    function fputs (Strng : chars; Stream : FILEs) return int;
104    pragma Import (C, fputs, "fputs");
105
106    procedure free (Ptr : System.Address);
107    pragma Import (C, free, "free");
108
109    function freopen
110      (filename : chars;
111       mode     : chars;
112       stream   : FILEs;
113       encoding : Filename_Encoding := Unspecified) return FILEs;
114    pragma Import (C, freopen, "__gnat_freopen");
115
116    function fseek
117      (stream : FILEs;
118       offset : long;
119       origin : int)
120       return   int;
121    pragma Import (C, fseek, "fseek");
122
123    function ftell (stream : FILEs) return long;
124    pragma Import (C, ftell, "ftell");
125
126    function getenv (S : String) return System.Address;
127    pragma Import (C, getenv, "getenv");
128
129    function isatty (handle : int) return int;
130    pragma Import (C, isatty, "isatty");
131
132    function lseek (fd : int; offset : off_t; direction : int) return off_t;
133    pragma Import (C, lseek, "lseek");
134
135    function malloc (Size : size_t) return System.Address;
136    pragma Import (C, malloc, "malloc");
137
138    procedure memcpy (S1 : System.Address; S2 : System.Address; N : size_t);
139    pragma Import (C, memcpy, "memcpy");
140
141    procedure memmove (S1 : System.Address; S2 : System.Address; N : size_t);
142    pragma Import (C, memmove, "memmove");
143
144    procedure mktemp (template : chars);
145    pragma Import (C, mktemp, "mktemp");
146
147    function pclose (stream : System.Address) return int;
148    pragma Import (C, pclose, "pclose");
149
150    function popen (command, mode : System.Address) return System.Address;
151    pragma Import (C, popen, "popen");
152
153    function realloc
154      (Ptr : System.Address; Size : size_t) return System.Address;
155    pragma Import (C, realloc, "realloc");
156
157    procedure rewind (stream : FILEs);
158    pragma Import (C, rewind, "rewind");
159
160    function rmdir (dir_name : String) return int;
161    pragma Import (C, rmdir, "__gnat_rmdir");
162
163    function chdir (dir_name : String) return int;
164    pragma Import (C, chdir, "__gnat_chdir");
165
166    function setvbuf
167      (stream : FILEs;
168       buffer : chars;
169       mode   : int;
170       size   : size_t)
171       return   int;
172    pragma Import (C, setvbuf, "setvbuf");
173
174    procedure tmpnam (string : chars);
175    pragma Import (C, tmpnam, "tmpnam");
176
177    function tmpfile return FILEs;
178    pragma Import (C, tmpfile, "tmpfile");
179
180    function ungetc (c : int; stream : FILEs) return int;
181    pragma Import (C, ungetc, "ungetc");
182
183    function unlink (filename : chars) return int;
184    pragma Import (C, unlink, "__gnat_unlink");
185
186    function open (filename : chars; oflag : int) return int;
187    pragma Import (C, open, "open");
188
189    function close (fd : int) return int;
190    pragma Import (C, close, "close");
191
192    function read (fd : int; buffer : chars; nbytes : int) return int;
193    pragma Import (C, read, "read");
194
195    function write (fd : int; buffer : chars; nbytes : int) return int;
196    pragma Import (C, write, "write");
197
198    function strerror (errno : int) return chars_ptr;
199    pragma Import (C, strerror, "strerror");
200
201 end System.CRTL;