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