aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@gcc.gnu.org>2009-04-29 15:47:42 +0200
committerArnaud Charlet <charlet@gcc.gnu.org>2009-04-29 15:47:42 +0200
commit51ec70b8be4c423e38fcbc6e49add3fbc16fe5bb (patch)
treef8c5efa510fefa4a36802cbc8fcf62ab4d7580b4
parent9e895ab50a0882df6e42fdb2995fec55258a26d6 (diff)
downloadgcc-51ec70b8be4c423e38fcbc6e49add3fbc16fe5bb.zip
gcc-51ec70b8be4c423e38fcbc6e49add3fbc16fe5bb.tar.gz
gcc-51ec70b8be4c423e38fcbc6e49add3fbc16fe5bb.tar.bz2
[multiple changes]
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
-rw-r--r--gcc/ada/ChangeLog23
-rw-r--r--gcc/ada/g-socket.adb8
-rw-r--r--gcc/ada/g-socthi-mingw.ads11
-rw-r--r--gcc/ada/g-socthi-vms.ads12
-rw-r--r--gcc/ada/g-socthi-vxworks.ads11
-rw-r--r--gcc/ada/g-socthi.ads11
-rw-r--r--gcc/ada/g-sothco.ads15
-rw-r--r--gcc/ada/gnat_ugn.texi37
-rw-r--r--gcc/ada/s-oscons-tmplt.c13
-rw-r--r--gcc/ada/sem_aggr.adb3
10 files changed, 80 insertions, 64 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 8e69ece..553edf2 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -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
diff --git a/gcc/ada/g-socket.adb b/gcc/ada/g-socket.adb
index 7096405..63f6d74 100644
--- a/gcc/ada/g-socket.adb
+++ b/gcc/ada/g-socket.adb
@@ -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
diff --git a/gcc/ada/g-socthi-mingw.ads b/gcc/ada/g-socthi-mingw.ads
index f06f7a8..7b24eee 100644
--- a/gcc/ada/g-socthi-mingw.ads
+++ b/gcc/ada/g-socthi-mingw.ads
@@ -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
diff --git a/gcc/ada/g-socthi-vms.ads b/gcc/ada/g-socthi-vms.ads
index 6df9335..2fd5009 100644
--- a/gcc/ada/g-socthi-vms.ads
+++ b/gcc/ada/g-socthi-vms.ads
@@ -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
diff --git a/gcc/ada/g-socthi-vxworks.ads b/gcc/ada/g-socthi-vxworks.ads
index 88638f9..4b6bd34 100644
--- a/gcc/ada/g-socthi-vxworks.ads
+++ b/gcc/ada/g-socthi-vxworks.ads
@@ -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
diff --git a/gcc/ada/g-socthi.ads b/gcc/ada/g-socthi.ads
index 31cbce8..b5186d0 100644
--- a/gcc/ada/g-socthi.ads
+++ b/gcc/ada/g-socthi.ads
@@ -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
diff --git a/gcc/ada/g-sothco.ads b/gcc/ada/g-sothco.ads
index 4486771..9a86728 100644
--- a/gcc/ada/g-sothco.ads
+++ b/gcc/ada/g-sothco.ads
@@ -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 --
----------------------------
diff --git a/gcc/ada/gnat_ugn.texi b/gcc/ada/gnat_ugn.texi
index 31e7080..ec10ef1 100644
--- a/gcc/ada/gnat_ugn.texi
+++ b/gcc/ada/gnat_ugn.texi
@@ -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
diff --git a/gcc/ada/s-oscons-tmplt.c b/gcc/ada/s-oscons-tmplt.c
index c3511b9..24555f1 100644
--- a/gcc/ada/s-oscons-tmplt.c
+++ b/gcc/ada/s-oscons-tmplt.c
@@ -1181,6 +1181,19 @@ 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 ";")
+
+/*
+
----------------------------------------
-- Properties of supported interfaces --
----------------------------------------
diff --git a/gcc/ada/sem_aggr.adb b/gcc/ada/sem_aggr.adb
index 40f15ae..e7cb9cc 100644
--- a/gcc/ada/sem_aggr.adb
+++ b/gcc/ada/sem_aggr.adb
@@ -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));