1 ------------------------------------------------------------------------------
3 -- GNAT RUN-TIME COMPONENTS --
5 -- S Y S T E M . C R T L --
9 -- Copyright (C) 2003-2006, Free Software Foundation, Inc. --
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. --
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. --
29 -- GNAT was originally developed by the GNAT team at New York University. --
30 -- Extensive contributions were provided by Ada Core Technologies Inc. --
32 ------------------------------------------------------------------------------
34 -- This package provides the low level interface to the C Run Time Library
35 -- on non-VMS systems.
37 with System
.Parameters
;
39 package System
.CRTL
is
42 subtype chars
is System
.Address
;
43 -- Pointer to null-terminated array of characters
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 2 ** Standard
'Address_Size;
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
65 function atoi
(A
: System
.Address
) return Integer;
66 pragma Import
(C
, atoi
, "atoi");
68 procedure clearerr
(stream
: FILEs
);
69 pragma Import
(C
, clearerr
, "clearerr");
71 function dup
(handle
: int
) return int
;
72 pragma Import
(C
, dup
, "dup");
74 function dup2
(from
, to
: int
) return int
;
75 pragma Import
(C
, dup2
, "dup2");
77 function fclose
(stream
: FILEs
) return int
;
78 pragma Import
(C
, fclose
, "fclose");
80 function fdopen
(handle
: int
; mode
: chars
) return FILEs
;
81 pragma Import
(C
, fdopen
, "fdopen");
83 function fflush
(stream
: FILEs
) return int
;
84 pragma Import
(C
, fflush
, "fflush");
86 function fgetc
(stream
: FILEs
) return int
;
87 pragma Import
(C
, fgetc
, "fgetc");
89 function fgets
(strng
: chars
; n
: int
; stream
: FILEs
) return chars
;
90 pragma Import
(C
, fgets
, "fgets");
95 encoding
: Filename_Encoding
:= UTF8
) return FILEs
;
96 pragma Import
(C
, fopen
, "__gnat_fopen");
98 function fputc
(C
: int
; stream
: FILEs
) return int
;
99 pragma Import
(C
, fputc
, "fputc");
101 function fputs
(Strng
: chars
; Stream
: FILEs
) return int
;
102 pragma Import
(C
, fputs
, "fputs");
104 procedure free
(Ptr
: System
.Address
);
105 pragma Import
(C
, free
, "free");
111 encoding
: Filename_Encoding
:= UTF8
) return FILEs
;
112 pragma Import
(C
, freopen
, "__gnat_freopen");
119 pragma Import
(C
, fseek
, "fseek");
121 function ftell
(stream
: FILEs
) return long
;
122 pragma Import
(C
, ftell
, "ftell");
124 function getenv
(S
: String) return System
.Address
;
125 pragma Import
(C
, getenv
, "getenv");
127 function isatty
(handle
: int
) return int
;
128 pragma Import
(C
, isatty
, "isatty");
130 function lseek
(fd
: int
; offset
: off_t
; direction
: int
) return off_t
;
131 pragma Import
(C
, lseek
, "lseek");
133 function malloc
(Size
: size_t
) return System
.Address
;
134 pragma Import
(C
, malloc
, "malloc");
136 procedure memcpy
(S1
: System
.Address
; S2
: System
.Address
; N
: size_t
);
137 pragma Import
(C
, memcpy
, "memcpy");
139 procedure memmove
(S1
: System
.Address
; S2
: System
.Address
; N
: size_t
);
140 pragma Import
(C
, memmove
, "memmove");
142 procedure mktemp
(template
: chars
);
143 pragma Import
(C
, mktemp
, "mktemp");
145 function pclose
(stream
: System
.Address
) return int
;
146 pragma Import
(C
, pclose
, "pclose");
148 function popen
(command
, mode
: System
.Address
) return System
.Address
;
149 pragma Import
(C
, popen
, "popen");
151 function read
(fd
: int
; buffer
: chars
; nbytes
: int
) return int
;
152 pragma Import
(C
, read
, "read");
155 (Ptr
: System
.Address
; Size
: size_t
) return System
.Address
;
156 pragma Import
(C
, realloc
, "realloc");
158 procedure rewind
(stream
: FILEs
);
159 pragma Import
(C
, rewind
, "rewind");
161 procedure rmdir
(dir_name
: String);
162 pragma Import
(C
, rmdir
, "rmdir");
170 pragma Import
(C
, setvbuf
, "setvbuf");
172 procedure tmpnam
(string : chars
);
173 pragma Import
(C
, tmpnam
, "tmpnam");
175 function tmpfile
return FILEs
;
176 pragma Import
(C
, tmpfile
, "tmpfile");
178 function ungetc
(c
: int
; stream
: FILEs
) return int
;
179 pragma Import
(C
, ungetc
, "ungetc");
181 function unlink
(filename
: chars
) return int
;
182 pragma Import
(C
, unlink
, "unlink");
184 function write
(fd
: int
; buffer
: chars
; nbytes
: int
) return int
;
185 pragma Import
(C
, write
, "write");