Commit e1aca343 by Arnaud Charlet

[multiple changes]

2009-07-22  Ed Falis  <falis@adacore.com>

	* s-vxwext-kernel.adb, s-vxwext-kernel.ads: Replace use of taskStop
	with taskSuspend.

2009-07-22  Arnaud Charlet  <charlet@adacore.com>

	* adadecode.c: Make this file compilable outside of GCC.

2009-07-22  Thomas Quinot  <quinot@adacore.com>

	* g-socket.adb, g-socket.ads (Check_Selector): Make sure that
	(partially) default-initialized socket sets are handled properly by
	clearing their Set component.

2009-07-22  Bob Duff  <duff@adacore.com>

	* gnat_ugn.texi: Clarify the -gnatVx (validity checking) switches.

From-SVN: r149939
parent 74462a6a
2009-07-22 Ed Falis <falis@adacore.com>
* s-vxwext-kernel.adb, s-vxwext-kernel.ads: Replace use of taskStop
with taskSuspend.
2009-07-22 Arnaud Charlet <charlet@adacore.com>
* adadecode.c: Make this file compilable outside of GCC.
2009-07-22 Thomas Quinot <quinot@adacore.com>
* g-socket.adb, g-socket.ads (Check_Selector): Make sure that
(partially) default-initialized socket sets are handled properly by
clearing their Set component.
2009-07-22 Bob Duff <duff@adacore.com>
* gnat_ugn.texi: Clarify the -gnatVx (validity checking) switches.
2009-07-22 Robert Dewar <dewar@adacore.com> 2009-07-22 Robert Dewar <dewar@adacore.com>
* gnat_ugn.texi: Minor reformatting * gnat_ugn.texi: Minor reformatting
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include "config.h" #include "config.h"
#include "system.h" #include "system.h"
#else #else
#include <string.h>
#include <stdio.h> #include <stdio.h>
#include <ctype.h> #include <ctype.h>
#define ISDIGIT(c) isdigit(c) #define ISDIGIT(c) isdigit(c)
...@@ -324,6 +325,7 @@ __gnat_decode (const char *coded_name, char *ada_name, int verbose) ...@@ -324,6 +325,7 @@ __gnat_decode (const char *coded_name, char *ada_name, int verbose)
} }
} }
#ifdef IN_GCC
char * char *
ada_demangle (const char *coded_name) ada_demangle (const char *coded_name)
{ {
...@@ -332,6 +334,7 @@ ada_demangle (const char *coded_name) ...@@ -332,6 +334,7 @@ ada_demangle (const char *coded_name)
__gnat_decode (coded_name, ada_name, 0); __gnat_decode (coded_name, ada_name, 0);
return xstrdup (ada_name); return xstrdup (ada_name);
} }
#endif
void void
get_encoding (const char *coded_name, char *encoding) get_encoding (const char *coded_name, char *encoding)
......
...@@ -56,10 +56,6 @@ package body GNAT.Sockets is ...@@ -56,10 +56,6 @@ package body GNAT.Sockets is
ENOERROR : constant := 0; ENOERROR : constant := 0;
Empty_Socket_Set : Socket_Set_Type;
-- Variable set in Initialize, and then used internally to provide an
-- initial value for Socket_Set_Type objects.
Netdb_Buffer_Size : constant := SOSC.Need_Netdb_Buffer * 1024; Netdb_Buffer_Size : constant := SOSC.Need_Netdb_Buffer * 1024;
-- The network database functions gethostbyname, gethostbyaddr, -- The network database functions gethostbyname, gethostbyaddr,
-- getservbyname and getservbyport can either be guaranteed task safe by -- getservbyname and getservbyport can either be guaranteed task safe by
...@@ -264,6 +260,11 @@ package body GNAT.Sockets is ...@@ -264,6 +260,11 @@ package body GNAT.Sockets is
procedure Initialize (X : in out Sockets_Library_Controller); procedure Initialize (X : in out Sockets_Library_Controller);
procedure Finalize (X : in out Sockets_Library_Controller); procedure Finalize (X : in out Sockets_Library_Controller);
procedure Normalize_Empty_Socket_Set (S : in out Socket_Set_Type);
-- If S is the empty set (detected by Last = No_Socket), make sure its
-- fd_set component is actually cleared. Note that the case where it is
-- not can occur for an uninitialized Socket_Set_Type object.
--------- ---------
-- "+" -- -- "+" --
--------- ---------
...@@ -452,7 +453,7 @@ package body GNAT.Sockets is ...@@ -452,7 +453,7 @@ package body GNAT.Sockets is
Status : out Selector_Status; Status : out Selector_Status;
Timeout : Selector_Duration := Forever) Timeout : Selector_Duration := Forever)
is is
E_Socket_Set : Socket_Set_Type := Empty_Socket_Set; E_Socket_Set : Socket_Set_Type;
begin begin
Check_Selector Check_Selector
(Selector, R_Socket_Set, W_Socket_Set, E_Socket_Set, Status, Timeout); (Selector, R_Socket_Set, W_Socket_Set, E_Socket_Set, Status, Timeout);
...@@ -496,6 +497,12 @@ package body GNAT.Sockets is ...@@ -496,6 +497,12 @@ package body GNAT.Sockets is
C.int (W_Socket_Set.Last)), C.int (W_Socket_Set.Last)),
C.int (E_Socket_Set.Last)); C.int (E_Socket_Set.Last));
-- Zero out fd_set for empty Socket_Set_Type objects
Normalize_Empty_Socket_Set (R_Socket_Set);
Normalize_Empty_Socket_Set (W_Socket_Set);
Normalize_Empty_Socket_Set (E_Socket_Set);
Res := Res :=
C_Select C_Select
(Last + 1, (Last + 1,
...@@ -705,7 +712,7 @@ package body GNAT.Sockets is ...@@ -705,7 +712,7 @@ package body GNAT.Sockets is
procedure Copy procedure Copy
(Source : Socket_Set_Type; (Source : Socket_Set_Type;
Target : in out Socket_Set_Type) Target : out Socket_Set_Type)
is is
begin begin
Target := Source; Target := Source;
...@@ -760,7 +767,7 @@ package body GNAT.Sockets is ...@@ -760,7 +767,7 @@ package body GNAT.Sockets is
-- Empty -- -- Empty --
----------- -----------
procedure Empty (Item : in out Socket_Set_Type) is procedure Empty (Item : out Socket_Set_Type) is
begin begin
Reset_Socket_Set (Item.Set'Access); Reset_Socket_Set (Item.Set'Access);
Item.Last := No_Socket; Item.Last := No_Socket;
...@@ -1282,10 +1289,6 @@ package body GNAT.Sockets is ...@@ -1282,10 +1289,6 @@ package body GNAT.Sockets is
pragma Unreferenced (X); pragma Unreferenced (X);
begin begin
-- Initialization operation for the GNAT.Sockets package
Empty_Socket_Set.Last := No_Socket;
Reset_Socket_Set (Empty_Socket_Set.Set'Access);
Thin.Initialize; Thin.Initialize;
end Initialize; end Initialize;
...@@ -1408,6 +1411,17 @@ package body GNAT.Sockets is ...@@ -1408,6 +1411,17 @@ package body GNAT.Sockets is
end if; end if;
end Narrow; end Narrow;
--------------------------------
-- Normalize_Empty_Socket_Set --
--------------------------------
procedure Normalize_Empty_Socket_Set (S : in out Socket_Set_Type) is
begin
if S.Last = No_Socket then
Reset_Socket_Set (S.Set'Access);
end if;
end Normalize_Empty_Socket_Set;
------------------- -------------------
-- Official_Name -- -- Official_Name --
------------------- -------------------
...@@ -1445,7 +1459,6 @@ package body GNAT.Sockets is ...@@ -1445,7 +1459,6 @@ package body GNAT.Sockets is
R_Fd_Set : Socket_Set_Type; R_Fd_Set : Socket_Set_Type;
W_Fd_Set : Socket_Set_Type; W_Fd_Set : Socket_Set_Type;
-- Socket sets, empty at elaboration
begin begin
-- Create selector if not provided by the user -- Create selector if not provided by the user
...@@ -1470,14 +1483,6 @@ package body GNAT.Sockets is ...@@ -1470,14 +1483,6 @@ package body GNAT.Sockets is
Check_Selector (S.all, R_Fd_Set, W_Fd_Set, Status, Timeout); Check_Selector (S.all, R_Fd_Set, W_Fd_Set, Status, Timeout);
-- Cleanup actions (required in all cases to avoid memory leaks)
if For_Read then
Empty (R_Fd_Set);
else
Empty (W_Fd_Set);
end if;
if Selector = null then if Selector = null then
Close_Selector (S.all); Close_Selector (S.all);
end if; end if;
...@@ -1796,8 +1801,10 @@ package body GNAT.Sockets is ...@@ -1796,8 +1801,10 @@ package body GNAT.Sockets is
if Id = Socket_Error_Id then if Id = Socket_Error_Id then
return Resolve_Error (Val); return Resolve_Error (Val);
elsif Id = Host_Error_Id then elsif Id = Host_Error_Id then
return Resolve_Error (Val, False); return Resolve_Error (Val, False);
else else
return Cannot_Resolve_Error; return Cannot_Resolve_Error;
end if; end if;
......
...@@ -1010,7 +1010,9 @@ package GNAT.Sockets is ...@@ -1010,7 +1010,9 @@ package GNAT.Sockets is
type Socket_Set_Type is limited private; type Socket_Set_Type is limited private;
-- This type allows to manipulate sets of sockets. It allows to wait for -- This type allows to manipulate sets of sockets. It allows to wait for
-- events on multiple endpoints at one time. -- events on multiple endpoints at one time. This type has default
-- initialization, and the default value is the empty set.
--
-- Note: This type used to contain a pointer to dynamically allocated -- Note: This type used to contain a pointer to dynamically allocated
-- storage, but this is not the case anymore, and no special precautions -- storage, but this is not the case anymore, and no special precautions
-- are required to avoid memory leaks. -- are required to avoid memory leaks.
...@@ -1018,10 +1020,10 @@ package GNAT.Sockets is ...@@ -1018,10 +1020,10 @@ package GNAT.Sockets is
procedure Clear (Item : in out Socket_Set_Type; Socket : Socket_Type); procedure Clear (Item : in out Socket_Set_Type; Socket : Socket_Type);
-- Remove Socket from Item -- Remove Socket from Item
procedure Copy (Source : Socket_Set_Type; Target : in out Socket_Set_Type); procedure Copy (Source : Socket_Set_Type; Target : out Socket_Set_Type);
-- Copy Source into Target as Socket_Set_Type is limited private -- Copy Source into Target as Socket_Set_Type is limited private
procedure Empty (Item : in out Socket_Set_Type); procedure Empty (Item : out Socket_Set_Type);
-- Remove all Sockets from Item -- Remove all Sockets from Item
procedure Get (Item : in out Socket_Set_Type; Socket : out Socket_Type); procedure Get (Item : in out Socket_Set_Type; Socket : out Socket_Type);
...@@ -1141,7 +1143,12 @@ private ...@@ -1141,7 +1143,12 @@ private
type Socket_Set_Type is record type Socket_Set_Type is record
Last : Socket_Type := No_Socket; Last : Socket_Type := No_Socket;
-- Highest socket in set. Last = No_Socket denotes an empty set (which
-- is the default initial value).
Set : aliased Fd_Set; Set : aliased Fd_Set;
-- Underlying socket set. Note that the contents of this component is
-- undefined if Last = No_Socket.
end record; end record;
subtype Inet_Addr_Comp_Type is Natural range 0 .. 255; subtype Inet_Addr_Comp_Type is Natural range 0 .. 255;
...@@ -1188,9 +1195,7 @@ private ...@@ -1188,9 +1195,7 @@ private
subtype Name_Index is Natural range 1 .. Max_Name_Length; subtype Name_Index is Natural range 1 .. Max_Name_Length;
type Name_Type type Name_Type (Length : Name_Index := Max_Name_Length) is record
(Length : Name_Index := Max_Name_Length)
is record
Name : String (1 .. Length); Name : String (1 .. Length);
end record; end record;
-- We need fixed strings to avoid access types in host entry type -- We need fixed strings to avoid access types in host entry type
......
...@@ -4084,7 +4084,8 @@ Generate brief messages to @file{stderr} even if verbose mode set. ...@@ -4084,7 +4084,8 @@ Generate brief messages to @file{stderr} even if verbose mode set.
@item -gnatB @item -gnatB
@cindex @option{-gnatB} (@command{gcc}) @cindex @option{-gnatB} (@command{gcc})
Assume no invalid (bad) values except for 'Valid attribute use. Assume no invalid (bad) values except for 'Valid attribute use
(@pxref{Validity Checking}).
@item -gnatc @item -gnatc
@cindex @option{-gnatc} (@command{gcc}) @cindex @option{-gnatc} (@command{gcc})
...@@ -4327,8 +4328,7 @@ Verbose mode. Full error output with source lines to @file{stdout}. ...@@ -4327,8 +4328,7 @@ Verbose mode. Full error output with source lines to @file{stdout}.
@item -gnatV @item -gnatV
@cindex @option{-gnatV} (@command{gcc}) @cindex @option{-gnatV} (@command{gcc})
Control level of validity checking. See separate section describing Control level of validity checking (@pxref{Validity Checking}).
this feature.
@item ^-gnatw@var{xxx}^/WARNINGS=(@var{option}@r{[},@dots{}@r{]})^ @item ^-gnatw@var{xxx}^/WARNINGS=(@var{option}@r{[},@dots{}@r{]})^
@cindex @option{^-gnatw^/WARNINGS^} (@command{gcc}) @cindex @option{^-gnatw^/WARNINGS^} (@command{gcc})
...@@ -4586,7 +4586,7 @@ as warning mode modifiers (see description of @option{-gnatw}). ...@@ -4586,7 +4586,7 @@ as warning mode modifiers (see description of @option{-gnatw}).
@item @item
Once a ``V'' appears in the string (that is a use of the @option{-gnatV} Once a ``V'' appears in the string (that is a use of the @option{-gnatV}
switch), then all further characters in the switch are interpreted switch), then all further characters in the switch are interpreted
as validity checking options (see description of @option{-gnatV}). as validity checking options (@pxref{Validity Checking}).
@end ifclear @end ifclear
@end itemize @end itemize
...@@ -5854,35 +5854,52 @@ file. Note that this doesn't include traceback information. ...@@ -5854,35 +5854,52 @@ file. Note that this doesn't include traceback information.
@findex Validity Checking @findex Validity Checking
@noindent @noindent
The Ada Reference Manual has specific requirements for checking The Ada Reference Manual defines the concept of invalid values (see
for invalid values. In particular, RM 13.9.1 requires that the RM 13.9.1). The primary source of invalid values is uninitialized
evaluation of invalid values (for example from unchecked conversions), variables. A scalar variable that is left uninitialized may contain
not result in erroneous execution. In GNAT, the result of such an an invalid value; the concept of invalid does not apply to access or
evaluation in normal default mode is to either use the value composite types.
unmodified, or to raise Constraint_Error in those cases where use
of the unmodified value would cause erroneous execution. The cases It is an error to read an invalid value, but the RM does not require
where unmodified values might lead to erroneous execution are case run-time checks to detect such errors, except for some minimal
statements (where a wild jump might result from an invalid value), checking to prevent erroneous execution (i.e. unpredictable
and subscripts on the left hand side (where memory corruption could behavior). This corresponds to the @option{-gnatVd} switch below,
occur as a result of an invalid value). which is the default. For example, by default, if the expression of a
case statement is invalid, it will raise Constraint_Error rather than
causing a wild jump, and if an array index on the left-hand side of an
assignment is invalid, it will raise Constraint_Error rather than
overwriting an arbitrary memory location.
The @option{-gnatVa} may be used to enable additional validity checks,
which are not required by the RM. These checks are often very
expensive (which is why the RM does not require them). These checks
are useful in tracking down uninitialized variables, but they are
not usually recommended for production builds.
The other @option{-gnatV^@var{x}^^} switches below allow finer-grained
control; you can enable whichever validity checks you desire. However,
for most debugging purposes, @option{-gnatVa} is sufficient, and the
default @option{-gnatVd} (i.e. standard Ada behavior) is usually
sufficient for non-debugging use.
The @option{-gnatB} switch tells the compiler to assume that all The @option{-gnatB} switch tells the compiler to assume that all
values are valid (that is, within their declared subtype range) values are valid (that is, within their declared subtype range)
except in the context of a use of the Valid attribute. This means except in the context of a use of the Valid attribute. This means
the compiler can generate more efficient code, since the range the compiler can generate more efficient code, since the range
of values is better known at compile time. of values is better known at compile time. However, an uninitialized
variable can cause wild jumps and memory corruption in this mode.
The @option{-gnatV^@var{x}^^} switch allows more control over the validity The @option{-gnatV^@var{x}^^} switch allows control over the validity
checking mode. checking mode as described below.
@ifclear vms @ifclear vms
The @code{x} argument is a string of letters that The @code{x} argument is a string of letters that
indicate validity checks that are performed or not performed in addition indicate validity checks that are performed or not performed in addition
to the default checks described above. to the default checks required by Ada as described above.
@end ifclear @end ifclear
@ifset vms @ifset vms
The options allowed for this qualifier The options allowed for this qualifier
indicate validity checks that are performed or not performed in addition indicate validity checks that are performed or not performed in addition
to the default checks described above. to the default checks required by Ada as described above.
@end ifset @end ifset
@table @option @table @option
...@@ -75,4 +75,15 @@ package body System.VxWorks.Ext is ...@@ -75,4 +75,15 @@ package body System.VxWorks.Ext is
return ERROR; return ERROR;
end taskCpuAffinitySet; end taskCpuAffinitySet;
--------------
-- taskStop --
--------------
function Task_Stop (tid : t_id) return int is
function taskStop (tid : t_id) return int;
pragma Import (C, taskStop, "taskStop");
begin
return taskStop (tid);
end Task_Stop;
end System.VxWorks.Ext; end System.VxWorks.Ext;
...@@ -70,7 +70,7 @@ package System.VxWorks.Ext is ...@@ -70,7 +70,7 @@ package System.VxWorks.Ext is
pragma Import (C, Task_Cont, "taskCont"); pragma Import (C, Task_Cont, "taskCont");
function Task_Stop (tid : t_id) return int; function Task_Stop (tid : t_id) return int;
pragma Import (C, Task_Stop, "taskStop"); pragma Convention (C, Task_Stop);
function kill (pid : t_id; sig : int) return int; function kill (pid : t_id; sig : int) return int;
pragma Import (C, kill, "kill"); pragma Import (C, kill, "kill");
......
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