OSDN Git Service

2010-01-25 Bob Duff <duff@adacore.com>
[pf3gnuchains/gcc-fork.git] / gcc / ada / g-sothco.ads
index fc83047..82003e2 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 S p e c                                  --
 --                                                                          --
---                       Copyright (C) 2008, AdaCore                        --
+--                     Copyright (C) 2008-2009, AdaCore                     --
 --                                                                          --
 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -122,7 +122,7 @@ package GNAT.Sockets.Thin_Common is
       Sa_Family : Sockaddr_Length_And_Family;
       --  Address family (and address length on some platforms)
 
-      Sa_Data   : C.char_array (1 .. 14) := (others => C.nul);
+      Sa_Data : C.char_array (1 .. 14) := (others => C.nul);
       --  Family-specific data
       --  Note that some platforms require that all unused (reserved) bytes
       --  in addresses be initialized to 0 (e.g. VxWorks).
@@ -169,14 +169,15 @@ package GNAT.Sockets.Thin_Common is
       Sin_Family : Sockaddr_Length_And_Family;
       --  Address family (and address length on some platforms)
 
-      Sin_Port   : C.unsigned_short;
+      Sin_Port : C.unsigned_short;
       --  Port in network byte order
 
-      Sin_Addr   : In_Addr;
+      Sin_Addr : In_Addr;
       --  IPv4 address
 
-      Sin_Zero   : C.char_array (1 .. 8) := (others => C.nul);
+      Sin_Zero : C.char_array (1 .. 8) := (others => C.nul);
       --  Padding
+      --
       --  Note that some platforms require that all unused (reserved) bytes
       --  in addresses be initialized to 0 (e.g. VxWorks).
    end record;
@@ -211,19 +212,45 @@ package GNAT.Sockets.Thin_Common is
                       C.Strings.Null_Ptr);
    --  Arrays of C (char *)
 
-   type Servent is record
-      S_Name    : C.Strings.chars_ptr;
-      S_Aliases : Chars_Ptr_Pointers.Pointer;
-      S_Port    : C.int;
-      S_Proto   : C.Strings.chars_ptr;
-   end record;
-   pragma Convention (C, Servent);
-   --  Service entry
+   type Servent is new
+     System.Storage_Elements.Storage_Array (1 .. SOSC.SIZEOF_struct_servent);
+   for Servent'Alignment use 8;
+   --  Service entry. This is an opaque type used only via the following
+   --  accessor functions, because 'struct servent' has different layouts on
+   --  different platforms.
 
    type Servent_Access is access all Servent;
    pragma Convention (C, Servent_Access);
    --  Access to service entry
 
+   function Servent_S_Name
+     (E : Servent_Access) return C.Strings.chars_ptr;
+
+   function Servent_S_Aliases
+     (E : Servent_Access) return Chars_Ptr_Pointers.Pointer;
+
+   function Servent_S_Port
+     (E : Servent_Access) return C.int;
+
+   function Servent_S_Proto
+     (E : Servent_Access) return C.Strings.chars_ptr;
+
+   procedure Servent_Set_S_Name
+     (E      : Servent_Access;
+      S_Name : C.Strings.chars_ptr);
+
+   procedure Servent_Set_S_Aliases
+     (E         : Servent_Access;
+      S_Aliases : Chars_Ptr_Pointers.Pointer);
+
+   procedure Servent_Set_S_Port
+     (E      : Servent_Access;
+      S_Port : C.int);
+
+   procedure Servent_Set_S_Proto
+     (E       : Servent_Access;
+      S_Proto : C.Strings.chars_ptr);
+
    ------------------
    -- Host entries --
    ------------------
@@ -242,18 +269,29 @@ package GNAT.Sockets.Thin_Common is
    pragma Convention (C, Hostent_Access);
    --  Access to host entry
 
+   ------------------------------------
+   -- Scatter/gather vector handling --
+   ------------------------------------
+
+   type Msghdr is record
+      Msg_Name       : System.Address;
+      Msg_Namelen    : C.unsigned;
+      Msg_Iov        : System.Address;
+      Msg_Iovlen     : SOSC.Msg_Iovlen_T;
+      Msg_Control    : System.Address;
+      Msg_Controllen : C.size_t;
+      Msg_Flags      : C.int;
+   end record;
+   pragma Convention (C, Msghdr);
+
    ----------------------------
    -- Socket sets management --
    ----------------------------
 
-   type Int_Access is access all C.int;
-   pragma Convention (C, Int_Access);
-   --  Access to C integers
-
    procedure Get_Socket_From_Set
      (Set    : access Fd_Set;
-      Socket : Int_Access;
-      Last   : Int_Access);
+      Last   : access C.int;
+      Socket : access C.int);
    --  Get last socket in Socket and remove it from the socket set. The
    --  parameter Last is a maximum value of the largest socket. This hint is
    --  used to avoid scanning very large socket sets. After a call to
@@ -272,8 +310,8 @@ package GNAT.Sockets.Thin_Common is
    --  value if it is, zero if it is not.
 
    procedure Last_Socket_In_Set
-     (Set    : access Fd_Set;
-      Last   : Int_Access);
+     (Set  : access Fd_Set;
+      Last : access C.int);
    --  Find the largest socket in the socket set. This is needed for select().
    --  When Last_Socket_In_Set is called, parameter Last is a maximum value of
    --  the largest socket. This hint is used to avoid scanning very large
@@ -304,6 +342,16 @@ package GNAT.Sockets.Thin_Common is
    --  Indices into an Fd_Pair value providing access to each of the connected
    --  file descriptors.
 
+   function Inet_Pton
+     (Af  : C.int;
+      Cp  : C.Strings.chars_ptr;
+      Inp : System.Address) return C.int;
+
+   function C_Ioctl
+     (Fd  : C.int;
+      Req : C.int;
+      Arg : access C.int) return C.int;
+
 private
    pragma Import (C, Get_Socket_From_Set, "__gnat_get_socket_from_set");
    pragma Import (C, Is_Socket_In_Set, "__gnat_is_socket_in_set");
@@ -311,4 +359,15 @@ private
    pragma Import (C, Insert_Socket_In_Set, "__gnat_insert_socket_in_set");
    pragma Import (C, Remove_Socket_From_Set, "__gnat_remove_socket_from_set");
    pragma Import (C, Reset_Socket_Set, "__gnat_reset_socket_set");
+   pragma Import (C, C_Ioctl, "__gnat_socket_ioctl");
+   pragma Import (C, Inet_Pton, SOSC.Inet_Pton_Linkname);
+
+   pragma Import (C, Servent_S_Name, "__gnat_servent_s_name");
+   pragma Import (C, Servent_S_Aliases, "__gnat_servent_s_aliases");
+   pragma Import (C, Servent_S_Port, "__gnat_servent_s_port");
+   pragma Import (C, Servent_S_Proto, "__gnat_servent_s_proto");
+   pragma Import (C, Servent_Set_S_Name, "__gnat_servent_set_s_name");
+   pragma Import (C, Servent_Set_S_Aliases, "__gnat_servent_set_s_aliases");
+   pragma Import (C, Servent_Set_S_Port, "__gnat_servent_set_s_port");
+   pragma Import (C, Servent_Set_S_Proto, "__gnat_servent_set_s_proto");
 end GNAT.Sockets.Thin_Common;