[multiple changes]
authorArnaud Charlet <charlet@gcc.gnu.org>
Wed, 29 Apr 2009 13:47:42 +0000 (15:47 +0200)
committerArnaud Charlet <charlet@gcc.gnu.org>
Wed, 29 Apr 2009 13:47:42 +0000 (15:47 +0200)
2009-04-29  Arnaud Charlet  <charlet@adacore.com>

* gnat_ugn.texi: Update some documentation about interfacing with C++
Mention -fkeep-inline-functions.

* gnat_ugn.texi: Minor edits

2009-04-29  Ed Schonberg  <schonberg@adacore.com>

* sem_aggr.adb (Resolve_Record_Aggregate): When building an aggregate
for a defaulted component of an enclosing aggregate, inherit the type
from the component declaration of the enclosing type.

2009-04-29  Albert Lee  <lee@adacore.com>

* g-socthi-vms.ads, g-socthi-vxworks.ads, s-oscons-tmplt.c,
g-socthi-mingw.ads, g-socthi.ads, g-socket.adb, g-sothco.ads
(System.OS_Constants): New type Msg_Iovlen_T which follows whether the
msg_iovlen field in struct msghdr is 32 or 64 bits wide.
Relocate the Msghdr record type from GNAT.Sockets.Thin to
GNAT.Sockets.Common, and use System.OS_Constants.Msg_Iovlen_T as the
type for the Msg_Iovlen field.

From-SVN: r146969

gcc/ada/ChangeLog
gcc/ada/g-socket.adb
gcc/ada/g-socthi-mingw.ads
gcc/ada/g-socthi-vms.ads
gcc/ada/g-socthi-vxworks.ads
gcc/ada/g-socthi.ads
gcc/ada/g-sothco.ads
gcc/ada/gnat_ugn.texi
gcc/ada/s-oscons-tmplt.c
gcc/ada/sem_aggr.adb

index 8e69ece234d0dea76c81c290d6d24edb4b878930..553edf2d643a367ba999b71078aa3f6338a93d35 100644 (file)
@@ -1,3 +1,26 @@
+2009-04-29  Arnaud Charlet  <charlet@adacore.com>
+
+       * gnat_ugn.texi: Update some documentation about interfacing with C++
+       Mention -fkeep-inline-functions.
+
+       * gnat_ugn.texi: Minor edits
+
+2009-04-29  Ed Schonberg  <schonberg@adacore.com>
+
+       * sem_aggr.adb (Resolve_Record_Aggregate): When building an aggregate
+       for a defaulted component of an enclosing aggregate, inherit the type
+       from the component declaration of the enclosing type. 
+
+2009-04-29  Albert Lee  <lee@adacore.com>
+
+       * g-socthi-vms.ads, g-socthi-vxworks.ads, s-oscons-tmplt.c,
+       g-socthi-mingw.ads, g-socthi.ads, g-socket.adb, g-sothco.ads
+       (System.OS_Constants): New type Msg_Iovlen_T which follows whether the
+       msg_iovlen field in struct msghdr is 32 or 64 bits wide.
+       Relocate the Msghdr record type from GNAT.Sockets.Thin to
+       GNAT.Sockets.Common, and use System.OS_Constants.Msg_Iovlen_T as the
+       type for the Msg_Iovlen field.
+
 2009-04-29  Vincent Celier  <celier@adacore.com>
 
        * sinput-l.adb (Load_File): When preprocessing, set temporarily the
index 70964053074b8f2b70c809a35bab214cde771afd..63f6d748142982d95e0f316727301f67547e62e7 100644 (file)
@@ -1673,7 +1673,7 @@ package body GNAT.Sockets is
               (Msg_Name       => System.Null_Address,
                Msg_Namelen    => 0,
                Msg_Iov        => Vector'Address,
-               Msg_Iovlen     => Vector'Length,
+               Msg_Iovlen     => SOSC.Msg_Iovlen_T (Vector'Length),
                Msg_Control    => System.Null_Address,
                Msg_Controllen => 0,
                Msg_Flags      => 0);
@@ -1904,11 +1904,11 @@ package body GNAT.Sockets is
       Count  : out Ada.Streams.Stream_Element_Count;
       Flags  : Request_Flag_Type := No_Request_Flag)
    is
-      use type C.size_t;
+      use type SOSC.Msg_Iovlen_T;
 
       Res            : ssize_t;
-      Iov_Count      : C.size_t;
-      This_Iov_Count : C.size_t;
+      Iov_Count      : SOSC.Msg_Iovlen_T;
+      This_Iov_Count : SOSC.Msg_Iovlen_T;
       Msg            : Msghdr;
 
    begin
index f06f7a80a5505f034c3b138ea272c4282e5556c1..7b24eeec4e1f31f0931a2fd626816a9475fde9e1 100644 (file)
@@ -54,17 +54,6 @@ package GNAT.Sockets.Thin is
      .. +(2 ** (C.size_t'Size - 1) - 1);
    --  Signed type of the same size as size_t
 
-   type Msghdr is record
-      Msg_Name       : System.Address;
-      Msg_Namelen    : C.unsigned;
-      Msg_Iov        : System.Address;
-      Msg_Iovlen     : C.size_t;
-      Msg_Control    : System.Address;
-      Msg_Controllen : C.size_t;
-      Msg_Flags      : C.int;
-   end record;
-   pragma Convention (C, Msghdr);
-
    function Socket_Errno return Integer;
    --  Returns last socket error number
 
index 6df93351edde486545bcdc6b7f96108f12f49c20..2fd5009db15172d901555bc529e7f16f6c0f1128 100644 (file)
@@ -57,18 +57,6 @@ package GNAT.Sockets.Thin is
      .. +(2 ** (C.size_t'Size - 1) - 1);
    --  Signed type of the same size as size_t
 
-   type Msghdr is record
-      Msg_Name       : System.Address;
-      Msg_Namelen    : C.unsigned;
-      Msg_Iov        : System.Address;
-      Msg_Iovlen     : C.size_t;
-      Msg_Control    : System.Address;
-      Msg_Controllen : C.size_t;
-      Msg_Flags      : C.int;
-   end record;
-   pragma Convention (C, Msghdr);
-   --  This type needs comments???
-
    function Socket_Errno return Integer renames GNAT.OS_Lib.Errno;
    --  Returns last socket error number
 
index 88638f99d0217c47b2ff29cc4ed8dd1d2d5d9fab..4b6bd34d080a01e28c9ddb99624d2d01b65df913 100644 (file)
@@ -55,17 +55,6 @@ package GNAT.Sockets.Thin is
      .. +(2 ** (C.size_t'Size - 1) - 1);
    --  Signed type of the same size as size_t
 
-   type Msghdr is record
-      Msg_Name       : System.Address;
-      Msg_Namelen    : C.unsigned;
-      Msg_Iov        : System.Address;
-      Msg_Iovlen     : C.size_t;
-      Msg_Control    : System.Address;
-      Msg_Controllen : C.size_t;
-      Msg_Flags      : C.int;
-   end record;
-   pragma Convention (C, Msghdr);
-
    function Socket_Errno return Integer renames GNAT.OS_Lib.Errno;
    --  Returns last socket error number
 
index 31cbce8148f9f992929663e9da73a54a46ad215c..b5186d062c619946e904e8fa8a4afc89e8d45328 100644 (file)
@@ -59,17 +59,6 @@ package GNAT.Sockets.Thin is
      .. +(2 ** (C.size_t'Size - 1) - 1);
    --  Signed type of the same size as size_t
 
-   type Msghdr is record
-      Msg_Name       : System.Address;
-      Msg_Namelen    : C.unsigned;
-      Msg_Iov        : System.Address;
-      Msg_Iovlen     : C.size_t;
-      Msg_Control    : System.Address;
-      Msg_Controllen : C.size_t;
-      Msg_Flags      : C.int;
-   end record;
-   pragma Convention (C, Msghdr);
-
    function Socket_Errno return Integer renames GNAT.OS_Lib.Errno;
    --  Returns last socket error number
 
index 448677174a8639e82e8cba8f5139b32df302659a..9a8672830fa636093cac1baa7f24946e98098f1d 100644 (file)
@@ -243,6 +243,21 @@ 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 --
    ----------------------------
index 31e7080fb2cc2fdb81d2c7a7beeeb8b19c371ad7..ec10ef1021c889b1386b52cd45a51b11c6380b54 100644 (file)
@@ -2992,17 +2992,18 @@ Interface ---see http://www.codesourcery.com/archives/cxx-abi).
 Interfacing can be done at 3 levels: simple data, subprograms, and
 classes. In the first two cases, GNAT offers a specific @code{Convention
 C_Plus_Plus} (or @code{CPP}) that behaves exactly like @code{Convention C}.
-Usually, C++ mangles the names of subprograms, and currently, GNAT does
-not provide any help to solve the demangling problem. This problem can be
-addressed in two ways:
+Usually, C++ mangles the names of subprograms. To generate proper mangled
+names automatically, see @ref{Generating Ada Bindings for C and C++ headers}).
+This problem can also be addressed manually in two ways:
+
 @itemize @bullet
 @item
 by modifying the C++ code in order to force a C convention using
 the @code{extern "C"} syntax.
 
 @item
-by figuring out the mangled name and use it as the Link_Name argument of
-the pragma import.
+by figuring out the mangled name (using e.g. @command{nm}) and using it as the
+Link_Name argument of the pragma import.
 @end itemize
 
 @noindent
@@ -3025,15 +3026,17 @@ considered:
 @item
 Using GNAT and G++ (GNU C++ compiler) from the same GCC installation:
 The C++ linker can simply be called by using the C++ specific driver
-called @code{c++}. Note that this setup is not very common because it
-may involve recompiling the whole GCC tree from sources, which makes it
-harder to upgrade the compilation system for one language without
-destabilizing the other.
+called @code{g++}.
+
+Note that if the C++ code uses inline functions, you will need to
+compile your C++ code with the @code{-fkeep-inline-functions} switch in
+order to provide an existing function implementation that the Ada code can
+link with.
 
 @smallexample
-$ c++ -c file1.C
-$ c++ -c file2.C
-$ gnatmake ada_unit -largs file1.o file2.o --LINK=c++
+$ g++ -c -fkeep-inline-functions file1.C
+$ g++ -c -fkeep-inline-functions file2.C
+$ gnatmake ada_unit -largs file1.o file2.o --LINK=g++
 @end smallexample
 
 @item
@@ -3105,6 +3108,10 @@ a pre-linking phase using GNAT will be necessary.
 
 @end enumerate
 
+Another alternative is to use the @command{gprbuild} multi-language builder
+which has a large knowledge base and knows how to link Ada and C++ code
+together automatically in most cases.
+
 @node A Simple Example
 @subsection  A Simple Example
 @noindent
@@ -3122,10 +3129,10 @@ languages.
 Here are the compilation commands:
 @smallexample
 $ gnatmake -c simple_cpp_interface
-$ c++ -c cpp_main.C
-$ c++ -c ex7.C
+$ g++ -c cpp_main.C
+$ g++ -c ex7.C
 $ gnatbind -n simple_cpp_interface
-$ gnatlink simple_cpp_interface -o cpp_main --LINK=$(CPLUSPLUS)
+$ gnatlink simple_cpp_interface -o cpp_main --LINK=g++
       -lstdc++ ex7.o cpp_main.o
 @end smallexample
 
index c3511b9b52f10d6f1951e5df9c6b4e8861300fca..24555f1278adf66d578a0ac66d3bccaee4b6a517 100644 (file)
@@ -1179,6 +1179,19 @@ CND(SIZEOF_fd_set, "fd_set");
 TXT("   subtype H_Addrtype_T is Interfaces.C." h_addrtype_t ";")
 TXT("   subtype H_Length_T   is Interfaces.C." h_length_t ";")
 
+/*
+
+   --  Fields of struct msghdr
+*/
+
+#if defined (__VMS) || defined (__sun__) || defined (__hpux__)
+# define msg_iovlen_t "int"
+#else
+# define msg_iovlen_t "size_t"
+#endif
+
+TXT("   subtype Msg_Iovlen_T is Interfaces.C." msg_iovlen_t ";")
+
 /*
 
    ----------------------------------------
index 40f15aec019178b9706ffe5fd3793c5d6ce37771..e7cb9cc1651cbf4f68f5f8f381f038dcfdb83140 100644 (file)
@@ -3298,6 +3298,8 @@ package body Sem_Aggr is
                      --  We build a partially initialized aggregate with the
                      --  values of the discriminants and box initialization
                      --  for the rest, if other components are present.
+                     --  The type of the aggregate is the known subtype of
+                     --  the component.
 
                      declare
                         Loc        : constant Source_Ptr := Sloc (N);
@@ -3309,6 +3311,7 @@ package body Sem_Aggr is
 
                      begin
                         Expr := Make_Aggregate (Loc, New_List, New_List);
+                        Set_Etype (Expr, Ctyp);
 
                         Discr_Elmt :=
                           First_Elmt (Discriminant_Constraint (Ctyp));