PR_GET_NAME : constant := 16;
function prctl
- (option : int;
- arg2, arg3, arg4, arg5 : unsigned_long := 0) return int;
- pragma Import (C, prctl);
+ (option : int;
+ arg : unsigned_long) return int;
+ pragma Import (C_Variadic_1, prctl, "prctl");
-------------
-- Threads --
-- Stack --
-----------
+ subtype char_array is Interfaces.C.char_array;
+
type stack_t is record
ss_sp : System.Address;
ss_flags : int;
oss : access stack_t) return int;
pragma Import (C, sigaltstack, "sigaltstack");
- Alternate_Stack : aliased System.Address;
- pragma Import (C, Alternate_Stack, "__gnat_alternate_stack");
- -- The alternate signal stack for stack overflows
-
Alternate_Stack_Size : constant := 16 * 1024;
-- This must be in keeping with init.c:__gnat_alternate_stack
+ Alternate_Stack : aliased char_array (1 .. Alternate_Stack_Size);
+ pragma Import (C, Alternate_Stack, "__gnat_alternate_stack");
+ -- The alternate signal stack for stack overflows
+
function Get_Stack_Base (thread : pthread_t) return Address;
pragma Inline (Get_Stack_Base);
-- This is a dummy procedure to share some GNULLI files
type pid_t is new int;
- subtype char_array is Interfaces.C.char_array;
-
type pthread_attr_t is record
Data : char_array (1 .. OS_Constants.PTHREAD_ATTR_SIZE);
end record;
---------------
procedure To_Stderr (C : Character) is
- procedure Put_Char_Stderr (C : Character);
+ procedure Put_Char_Stderr (C : Integer);
pragma Import (C, Put_Char_Stderr, "put_char_stderr");
begin
- Put_Char_Stderr (C);
+ Put_Char_Stderr (Character'Pos (C));
end To_Stderr;
procedure To_Stderr (S : String) is
end Get;
procedure Get (C : out Character) is
- function Get_Char return Character;
+ function Get_Char return Integer;
pragma Import (C, Get_Char, "get_char");
begin
- C := Get_Char;
+ C := Character'Val (Get_Char);
end Get;
--------------
end Put;
procedure Put (File : File_Type; C : Character) is
- procedure Put_Char (C : Character);
+ procedure Put_Char (C : Integer);
pragma Import (C, Put_Char, "put_char");
- procedure Put_Char_Stderr (C : Character);
+ procedure Put_Char_Stderr (C : Integer);
pragma Import (C, Put_Char_Stderr, "put_char_stderr");
begin
case File is
- when Stdout => Put_Char (C);
- when Stderr => Put_Char_Stderr (C);
+ when Stdout => Put_Char (Character'Pos (C));
+ when Stderr => Put_Char_Stderr (Character'Pos (C));
end case;
end Put;
pragma Unreferenced (Family);
HA : aliased In_Addr_Union (Address.Family);
- Buflen : constant C.int := Netdb_Buffer_Size;
+ Buflen : constant C.size_t := Netdb_Buffer_Size;
Buf : aliased C.char_array (1 .. Netdb_Buffer_Size);
Res : aliased Hostent;
Err : aliased C.int;
declare
HN : constant C.char_array := C.To_C (Name);
- Buflen : constant C.int := Netdb_Buffer_Size;
+ Buflen : constant C.size_t := Netdb_Buffer_Size;
Buf : aliased C.char_array (1 .. Netdb_Buffer_Size);
Res : aliased Hostent;
Err : aliased C.int;
is
SN : constant C.char_array := C.To_C (Name);
SP : constant C.char_array := C.To_C (Protocol);
- Buflen : constant C.int := Netdb_Buffer_Size;
+ Buflen : constant C.size_t := Netdb_Buffer_Size;
Buf : aliased C.char_array (1 .. Netdb_Buffer_Size);
Res : aliased Servent;
Protocol : String) return Service_Entry_Type
is
SP : constant C.char_array := C.To_C (Protocol);
- Buflen : constant C.int := Netdb_Buffer_Size;
+ Buflen : constant C.size_t := Netdb_Buffer_Size;
Buf : aliased C.char_array (1 .. Netdb_Buffer_Size);
Res : aliased Servent;
function Syscall_Recv
(S : C.int;
Msg : System.Address;
- Len : C.int;
- Flags : C.int) return C.int;
+ Len : C.size_t;
+ Flags : C.int) return System.CRTL.ssize_t;
pragma Import (C, Syscall_Recv, "recv");
function Syscall_Recvfrom
(S : C.int;
Msg : System.Address;
- Len : C.int;
+ Len : C.size_t;
Flags : C.int;
From : System.Address;
- Fromlen : not null access C.int) return C.int;
+ Fromlen : not null access C.int) return System.CRTL.ssize_t;
pragma Import (C, Syscall_Recvfrom, "recvfrom");
function Syscall_Recvmsg
function Syscall_Sendto
(S : C.int;
Msg : System.Address;
- Len : C.int;
+ Len : C.size_t;
Flags : C.int;
To : System.Address;
- Tolen : C.int) return C.int;
+ Tolen : C.int) return System.CRTL.ssize_t;
pragma Import (C, Syscall_Sendto, "sendto");
function Syscall_Socket
function C_Recv
(S : C.int;
Msg : System.Address;
- Len : C.int;
+ Len : C.size_t;
Flags : C.int) return C.int
is
Res : C.int;
begin
loop
- Res := Syscall_Recv (S, Msg, Len, Flags);
+ Res := C.int (Syscall_Recv (S, Msg, Len, Flags));
exit when SOSC.Thread_Blocking_IO
or else Res /= Failure
or else Non_Blocking_Socket (S)
function C_Recvfrom
(S : C.int;
Msg : System.Address;
- Len : C.int;
+ Len : C.size_t;
Flags : C.int;
From : System.Address;
Fromlen : not null access C.int) return C.int
begin
loop
- Res := Syscall_Recvfrom (S, Msg, Len, Flags, From, Fromlen);
+ Res := C.int (Syscall_Recvfrom (S, Msg, Len, Flags, From, Fromlen));
exit when SOSC.Thread_Blocking_IO
or else Res /= Failure
or else Non_Blocking_Socket (S)
function C_Sendto
(S : C.int;
Msg : System.Address;
- Len : C.int;
+ Len : C.size_t;
Flags : C.int;
To : System.Address;
Tolen : C.int) return C.int
begin
loop
- Res := Syscall_Sendto (S, Msg, Len, Flags, To, Tolen);
+ Res := C.int (Syscall_Sendto (S, Msg, Len, Flags, To, Tolen));
exit when SOSC.Thread_Blocking_IO
or else Res /= Failure
or else Non_Blocking_Socket (S)
function C_Gethostname
(Name : System.Address;
- Namelen : C.int) return C.int;
+ Namelen : C.size_t) return C.int;
function C_Getpeername
(S : C.int;
function C_Recv
(S : C.int;
Msg : System.Address;
- Len : C.int;
+ Len : C.size_t;
Flags : C.int) return C.int;
function C_Recvfrom
(S : C.int;
Msg : System.Address;
- Len : C.int;
+ Len : C.size_t;
Flags : C.int;
From : System.Address;
Fromlen : not null access C.int) return C.int;
function C_Sendto
(S : C.int;
Msg : System.Address;
- Len : C.int;
+ Len : C.size_t;
Flags : C.int;
To : System.Address;
Tolen : C.int) return C.int;
function Syscall_Recv
(S : C.int;
Msg : System.Address;
- Len : C.int;
+ Len : C.size_t;
Flags : C.int) return C.int;
pragma Import (C, Syscall_Recv, "recv");
function Syscall_Recvfrom
(S : C.int;
Msg : System.Address;
- Len : C.int;
+ Len : C.size_t;
Flags : C.int;
From : System.Address;
Fromlen : not null access C.int) return C.int;
function Syscall_Send
(S : C.int;
Msg : System.Address;
- Len : C.int;
- Flags : C.int) return C.int;
+ Len : C.size_t;
+ Flags : C.int) return System.CRTL.ssize_t;
pragma Import (C, Syscall_Send, "send");
function Syscall_Sendto
(S : C.int;
Msg : System.Address;
- Len : C.int;
+ Len : C.size_t;
Flags : C.int;
To : System.Address;
- Tolen : C.int) return C.int;
+ Tolen : C.int) return System.CRTL.ssize_t;
pragma Import (C, Syscall_Sendto, "sendto");
function Syscall_Socket
function C_Recv
(S : C.int;
Msg : System.Address;
- Len : C.int;
+ Len : C.size_t;
Flags : C.int) return C.int
is
Res : C.int;
function C_Recvfrom
(S : C.int;
Msg : System.Address;
- Len : C.int;
+ Len : C.size_t;
Flags : C.int;
From : System.Address;
Fromlen : not null access C.int) return C.int
function C_Sendto
(S : C.int;
Msg : System.Address;
- Len : C.int;
+ Len : C.size_t;
Flags : C.int;
To : System.Address;
Tolen : C.int) return C.int
-- support sendto(2) calls on connected sockets with a null
-- destination address, so use send(2) instead in that case.
- Res := Syscall_Send (S, Msg, Len, Flags);
+ Res := C.int (Syscall_Send (S, Msg, Len, Flags));
-- Normal case where destination address is non-null
else
- Res := Syscall_Sendto (S, Msg, Len, Flags, To, Tolen);
+ Res := C.int (Syscall_Sendto (S, Msg, Len, Flags, To, Tolen));
end if;
exit when SOSC.Thread_Blocking_IO
function C_Gethostname
(Name : System.Address;
- Namelen : C.int) return C.int;
+ Namelen : C.size_t) return C.int;
function C_Getpeername
(S : C.int;
function C_Recv
(S : C.int;
Msg : System.Address;
- Len : C.int;
+ Len : C.size_t;
Flags : C.int) return C.int;
function C_Recvfrom
(S : C.int;
Msg : System.Address;
- Len : C.int;
+ Len : C.size_t;
Flags : C.int;
From : System.Address;
Fromlen : not null access C.int) return C.int;
function C_Sendto
(S : C.int;
Msg : System.Address;
- Len : C.int;
+ Len : C.size_t;
Flags : C.int;
To : System.Address;
Tolen : C.int) return C.int;
(Name : C.char_array;
Ret : not null access Hostent;
Buf : System.Address;
- Buflen : C.int;
+ Buflen : C.size_t;
H_Errnop : not null access C.int) return C.int;
function C_Gethostbyaddr
Addr_Type : C.int;
Ret : not null access Hostent;
Buf : System.Address;
- Buflen : C.int;
+ Buflen : C.size_t;
H_Errnop : not null access C.int) return C.int;
function C_Getservbyname
Proto : C.char_array;
Ret : not null access Servent;
Buf : System.Address;
- Buflen : C.int) return C.int;
+ Buflen : C.size_t) return C.int;
function C_Getservbyport
(Port : C.int;
Proto : C.char_array;
Ret : not null access Servent;
Buf : System.Address;
- Buflen : C.int) return C.int;
+ Buflen : C.size_t) return C.int;
Address_Size : constant := Standard'Address_Size;
end Put;
procedure Put (C : Character) is
- procedure Put_Char (C : Character);
+ procedure Put_Char (C : Integer);
pragma Import (C, Put_Char, "put_char");
- procedure Put_Char_Stderr (C : Character);
+ procedure Put_Char_Stderr (C : Integer);
pragma Import (C, Put_Char_Stderr, "put_char_stderr");
begin
case Current_Out is
- when Stdout => Put_Char (C);
- when Stderr => Put_Char_Stderr (C);
+ when Stdout => Put_Char (Character'Pos (C));
+ when Stderr => Put_Char_Stderr (Character'Pos (C));
end case;
end Put;