-- This package provides the low level interface to the C runtime library
+pragma Compiler_Unit;
+
with System.Parameters;
package System.CRTL is
subtype chars is System.Address;
-- Pointer to null-terminated array of characters
+ -- Should use Interfaces.C.Strings types instead, but this causes bootstrap
+ -- issues as i-c contains Ada 2005 specific features, not compatible with
+ -- older, Ada 95-only base compilers???
subtype DIRs is System.Address;
-- Corresponds to the C type DIR*
subtype int is Integer;
type long is range -(2 ** (System.Parameters.long_bits - 1))
- .. +(2 ** (System.Parameters.long_bits - 1)) - 1;
+ .. +(2 ** (System.Parameters.long_bits - 1)) - 1;
subtype off_t is Long_Integer;
type size_t is mod 2 ** Standard'Address_Size;
+ type ssize_t is range -(2 ** (Standard'Address_Size - 1))
+ .. +(2 ** (Standard'Address_Size - 1)) - 1;
+
type Filename_Encoding is (UTF8, ASCII_8bits, Unspecified);
for Filename_Encoding use (UTF8 => 0, ASCII_8bits => 1, Unspecified => 2);
pragma Convention (C, Filename_Encoding);
function fseek
(stream : FILEs;
offset : long;
- origin : int)
- return int;
+ origin : int) return int;
pragma Import (C, fseek, "fseek");
function ftell (stream : FILEs) return long;
(stream : FILEs;
buffer : chars;
mode : int;
- size : size_t)
- return int;
+ size : size_t) return int;
pragma Import (C, setvbuf, "setvbuf");
procedure tmpnam (string : chars);
function close (fd : int) return int;
pragma Import (C, close, "close");
- function read (fd : int; buffer : chars; nbytes : int) return int;
+ function read (fd : int; buffer : chars; count : size_t) return ssize_t;
pragma Import (C, read, "read");
- function write (fd : int; buffer : chars; nbytes : int) return int;
+ function write (fd : int; buffer : chars; count : size_t) return ssize_t;
pragma Import (C, write, "write");
- function strerror (errno : int) return chars;
- pragma Import (C, strerror, "strerror");
-
end System.CRTL;