Commit 51ec70b8 by Arnaud Charlet

[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
parent 9e895ab5
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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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 --
----------------------------
......
......@@ -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
......@@ -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 --
----------------------------------------
......
......@@ -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));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment