1 ------------------------------------------------------------------------------
3 -- GNAT RUN-TIME COMPONENTS --
5 -- S Y S T E M . C R T L --
9 -- Copyright (C) 2003-2005 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 function atoi
(A
: System
.Address
) return Integer;
61 pragma Import
(C
, atoi
, "atoi");
63 procedure clearerr
(stream
: FILEs
);
64 pragma Import
(C
, clearerr
, "clearerr");
66 function closedir
(directory
: DIRs
) return Integer;
67 pragma Import
(C
, closedir
, "closedir");
69 function dup
(handle
: int
) return int
;
70 pragma Import
(C
, dup
, "dup");
72 function dup2
(from
, to
: int
) return int
;
73 pragma Import
(C
, dup2
, "dup2");
75 function fclose
(stream
: FILEs
) return int
;
76 pragma Import
(C
, fclose
, "fclose");
78 function fdopen
(handle
: int
; mode
: chars
) return FILEs
;
79 pragma Import
(C
, fdopen
, "fdopen");
81 function fflush
(stream
: FILEs
) return int
;
82 pragma Import
(C
, fflush
, "fflush");
84 function fgetc
(stream
: FILEs
) return int
;
85 pragma Import
(C
, fgetc
, "fgetc");
87 function fgets
(strng
: chars
; n
: int
; stream
: FILEs
) return chars
;
88 pragma Import
(C
, fgets
, "fgets");
90 function fopen
(filename
: chars
; Mode
: chars
) return FILEs
;
91 pragma Import
(C
, fopen
, "fopen");
93 function fputc
(C
: int
; stream
: FILEs
) return int
;
94 pragma Import
(C
, fputc
, "fputc");
96 function fputs
(Strng
: chars
; Stream
: FILEs
) return int
;
97 pragma Import
(C
, fputs
, "fputs");
99 procedure free
(Ptr
: System
.Address
);
100 pragma Import
(C
, free
, "free");
107 pragma Import
(C
, freopen
, "freopen");
114 pragma Import
(C
, fseek
, "fseek");
116 function ftell
(stream
: FILEs
) return long
;
117 pragma Import
(C
, ftell
, "ftell");
119 function getenv
(S
: String) return System
.Address
;
120 pragma Import
(C
, getenv
, "getenv");
122 function isatty
(handle
: int
) return int
;
123 pragma Import
(C
, isatty
, "isatty");
125 function lseek
(fd
: int
; offset
: off_t
; direction
: int
) return off_t
;
126 pragma Import
(C
, lseek
, "lseek");
128 function malloc
(Size
: size_t
) return System
.Address
;
129 pragma Import
(C
, malloc
, "malloc");
131 procedure memcpy
(S1
: System
.Address
; S2
: System
.Address
; N
: size_t
);
132 pragma Import
(C
, memcpy
, "memcpy");
134 procedure memmove
(S1
: System
.Address
; S2
: System
.Address
; N
: size_t
);
135 pragma Import
(C
, memmove
, "memmove");
137 procedure mktemp
(template
: chars
);
138 pragma Import
(C
, mktemp
, "mktemp");
140 function opendir
(file_name
: String) return DIRs
;
141 pragma Import
(C
, opendir
, "opendir");
143 function pclose
(stream
: System
.Address
) return int
;
144 pragma Import
(C
, pclose
, "pclose");
146 function popen
(command
, mode
: System
.Address
) return System
.Address
;
147 pragma Import
(C
, popen
, "popen");
149 function read
(fd
: int
; buffer
: chars
; nbytes
: int
) return int
;
150 pragma Import
(C
, read
, "read");
153 (Ptr
: System
.Address
; Size
: size_t
) return System
.Address
;
154 pragma Import
(C
, realloc
, "realloc");
156 procedure rewind
(stream
: FILEs
);
157 pragma Import
(C
, rewind
, "rewind");
159 procedure rmdir
(dir_name
: String);
160 pragma Import
(C
, rmdir
, "rmdir");
168 pragma Import
(C
, setvbuf
, "setvbuf");
170 procedure tmpnam
(string : chars
);
171 pragma Import
(C
, tmpnam
, "tmpnam");
173 function tmpfile
return FILEs
;
174 pragma Import
(C
, tmpfile
, "tmpfile");
176 function ungetc
(c
: int
; stream
: FILEs
) return int
;
177 pragma Import
(C
, ungetc
, "ungetc");
179 function unlink
(filename
: chars
) return int
;
180 pragma Import
(C
, unlink
, "unlink");
182 function write
(fd
: int
; buffer
: chars
; nbytes
: int
) return int
;
183 pragma Import
(C
, write
, "write");