OSDN Git Service

Regenerate gcc/configure.
[pf3gnuchains/gcc-fork.git] / gcc / ada / s-os_lib.ads
index 2d624cf..341a279 100755 (executable)
@@ -6,25 +6,23 @@
 --                                                                          --
 --                                 S p e c                                  --
 --                                                                          --
---          Copyright (C) 1995-2007, Free Software Foundation, Inc.         --
+--          Copyright (C) 1995-2009, Free Software Foundation, Inc.         --
 --                                                                          --
 -- 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- --
--- ware  Foundation;  either version 2,  or (at your option) any later ver- --
+-- ware  Foundation;  either version 3,  or (at your option) any later ver- --
 -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
 -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
--- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
--- for  more details.  You should have  received  a copy of the GNU General --
--- Public License  distributed with GNAT;  see file COPYING.  If not, write --
--- to  the  Free Software Foundation,  51  Franklin  Street,  Fifth  Floor, --
--- Boston, MA 02110-1301, USA.                                              --
+-- or FITNESS FOR A PARTICULAR PURPOSE.                                     --
 --                                                                          --
--- As a special exception,  if other files  instantiate  generics from this --
--- unit, or you link  this unit with other files  to produce an executable, --
--- this  unit  does not  by itself cause  the resulting  executable  to  be --
--- covered  by the  GNU  General  Public  License.  This exception does not --
--- however invalidate  any other reasons why  the executable file  might be --
--- covered by the  GNU Public License.                                      --
+-- As a special exception under Section 7 of GPL version 3, you are granted --
+-- additional permissions described in the GCC Runtime Library Exception,   --
+-- version 3.1, as published by the Free Software Foundation.               --
+--                                                                          --
+-- You should have received a copy of the GNU General Public License and    --
+-- a copy of the GCC Runtime Library Exception along with this program;     --
+-- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    --
+-- <http://www.gnu.org/licenses/>.                                          --
 --                                                                          --
 -- GNAT was originally developed  by the GNAT team at  New York University. --
 -- Extensive contributions were provided by Ada Core Technologies Inc.      --
@@ -50,6 +48,8 @@
 --  be used by other predefined packages. User access to this package is via
 --  a renaming of this package in GNAT.OS_Lib (file g-os_lib.ads).
 
+pragma Compiler_Unit;
+
 with System;
 with System.Strings;
 
@@ -61,7 +61,7 @@ package System.OS_Lib is
    -----------------------
 
    --  These are reexported from package Strings (which was introduced to
-   --  avoid different packages declarting different types unnecessarily).
+   --  avoid different packages declaring different types unnecessarily).
    --  See package System.Strings for details.
 
    subtype String_Access is Strings.String_Access;
@@ -145,9 +145,9 @@ package System.OS_Lib is
       Hour   : out Hour_Type;
       Minute : out Minute_Type;
       Second : out Second_Type);
-   --  Analogous to the Split routine in Ada.Calendar, takes an OS_Time
-   --  and provides a representation of it as a set of component parts,
-   --  to be interpreted as a date point in UTC.
+   --  Analogous to the Split routine in Ada.Calendar, takes an OS_Time and
+   --  provides a representation of it as a set of component parts, to be
+   --  interpreted as a date point in UTC.
 
    ----------------
    -- File Stuff --
@@ -234,20 +234,37 @@ package System.OS_Lib is
    --  mode parameter is provided. Since this is a temporary file, there is no
    --  point in doing text translation on it.
    --
-   --  On some OSes, the maximum number of temp files that can be created with
-   --  this procedure may be limited. When the maximum is reached, this
-   --  procedure returns Invalid_FD. On some OSes, there may be a race
-   --  condition between processes trying to create temp files at the same
-   --  time in the same directory using this procedure.
+   --  On some operating systems, the maximum number of temp files that can be
+   --  created with this procedure may be limited. When the maximum is reached,
+   --  this procedure returns Invalid_FD. On some operating systems, there may
+   --  be a race condition between processes trying to create temp files at the
+   --  same time in the same directory using this procedure.
 
    procedure Create_Temp_File
      (FD   : out File_Descriptor;
       Name : out String_Access);
    --  Create and open for writing a temporary file in the current working
    --  directory. The name of the file and the File Descriptor are returned.
-   --  No mode parameter is provided. Since this is a temporary file, there is
-   --  no point in doing text translation on it. It is the responsibility of
-   --  the caller to deallocate the access value returned in Name.
+   --  It is the responsibility of the caller to deallocate the access value
+   --  returned in Name.
+   --
+   --  The file is opened in binary mode (no text translation).
+   --
+   --  This procedure will always succeed if the current working directory is
+   --  writable. If the current working directory is not writable, then
+   --  Invalid_FD is returned for the file descriptor and null for the Name.
+   --  There is no race condition problem between processes trying to create
+   --  temp files at the same time in the same directory.
+
+   procedure Create_Temp_Output_File
+     (FD   : out File_Descriptor;
+      Name : out String_Access);
+   --  Create and open for writing a temporary file in the current working
+   --  directory suitable to redirect standard output. The name of the file and
+   --  the File Descriptor are returned. It is the responsibility of the caller
+   --  to deallocate the access value returned in Name.
+   --
+   --  The file is opened in text mode
    --
    --  This procedure will always succeed if the current working directory is
    --  writable. If the current working directory is not writable, then
@@ -303,7 +320,7 @@ package System.OS_Lib is
       Append);
       --  If the target file exists, the contents of the source file is
       --  appended at the end. Otherwise the source file is just copied. The
-      --  time stamps and other file attributes are are preserved if the
+      --  time stamps and other file attributes are preserved if the
       --  destination file does not exist.
 
    type Attribute is
@@ -468,6 +485,14 @@ package System.OS_Lib is
    --  not actually be readable due to some other process having exclusive
    --  access.
 
+   function Is_Executable_File (Name : String) return Boolean;
+   --  Determines if the given string, Name, is the name of an existing file
+   --  that is executable. Returns True if so, False otherwise. Note that this
+   --  function simply interrogates the file attributes (e.g. using the C
+   --  function stat), so it does not indicate a situation in which a file may
+   --  not actually be readable due to some other process having exclusive
+   --  access.
+
    function Is_Writable_File (Name : String) return Boolean;
    --  Determines if the given string, Name, is the name of an existing file
    --  that is writable. Returns True if so, False otherwise. Note that this
@@ -486,26 +511,38 @@ package System.OS_Lib is
    --  span file systems and may refer to directories.
 
    procedure Set_Writable (Name : String);
-   --  Change the permissions on the named file to make it writable
-   --  for its owner.
+   --  Change permissions on the named file to make it writable for its owner
+
+   procedure Set_Non_Writable (Name : String);
+   --  Change permissions on the named file to make it non-writable for its
+   --  owner. The readable and executable permissions are not modified.
 
-   procedure Set_Read_Only (Name : String);
-   --  Change the permissions on the named file to make it non-writable
-   --  for its owner.
+   procedure Set_Read_Only (Name : String) renames Set_Non_Writable;
+   --  This renaming is provided for backwards compatibility with previous
+   --  versions. The use of Set_Non_Writable is preferred (clearer name).
 
    procedure Set_Executable (Name : String);
-   --  Change the permissions on the named file to make it executable
-   --  for its owner.
+   --  Change permissions on the named file to make it executable for its owner
+
+   procedure Set_Readable (Name : String);
+   --  Change permissions on the named file to make it readable for its
+   --  owner.
+
+   procedure Set_Non_Readable (Name : String);
+   --  Change permissions on the named file to make it non-readable for
+   --  its owner. The writable and executable permissions are not
+   --  modified.
 
    function Locate_Exec_On_Path
      (Exec_Name : String) return String_Access;
    --  Try to locate an executable whose name is given by Exec_Name in the
-   --  directories listed in the environment Path. If the Exec_Name doesn't
+   --  directories listed in the environment Path. If the Exec_Name does not
    --  have the executable suffix, it will be appended before the search.
-   --  Otherwise works like Locate_Regular_File below.
+   --  Otherwise works like Locate_Regular_File below. If the executable is
+   --  not found, null is returned.
    --
-   --  Note that this function allocates some memory for the returned value.
-   --  This memory needs to be deallocated after use.
+   --  Note that this function allocates memory for the returned value. This
+   --  memory needs to be deallocated after use.
 
    function Locate_Regular_File
      (File_Name : String;
@@ -531,10 +568,9 @@ package System.OS_Lib is
    --  the heap and should be freed after use to avoid storage leaks.
 
    function Get_Target_Debuggable_Suffix return String_Access;
-   --  Return the target debuggable suffix convention. Usually this is the
-   --  same as the convention for Get_Executable_Suffix. The result is
-   --  allocated on the heap and should be freed after use to avoid storage
-   --  leaks.
+   --  Return the target debuggable suffix convention. Usually this is the same
+   --  as the convention for Get_Executable_Suffix. The result is allocated on
+   --  the heap and should be freed after use to avoid storage leaks.
 
    function Get_Executable_Suffix return String_Access;
    --  Return the executable suffix convention. The result is allocated on the
@@ -603,6 +639,7 @@ package System.OS_Lib is
    function Is_Regular_File (Name : C_File_Name) return Boolean;
    function Is_Directory (Name : C_File_Name) return Boolean;
    function Is_Readable_File (Name : C_File_Name) return Boolean;
+   function Is_Executable_File (Name : C_File_Name) return Boolean;
    function Is_Writable_File (Name : C_File_Name) return Boolean;
    function Is_Symbolic_Link (Name : C_File_Name) return Boolean;
 
@@ -650,9 +687,9 @@ package System.OS_Lib is
    --  (notably Unix systems) a simple file name may also work (if the
    --  executable can be located in the path).
    --
-   --  "Spawn" should not be used in tasking applications. Why not??? More
-   --  documentation would be helpful here ??? Is it really tasking programs,
-   --  or tasking activity that cause trouble ???
+   --  "Spawn" should be avoided in tasking applications, since there are
+   --  subtle interactions between creating a process and signals/locks
+   --  that can cause troubles.
    --
    --  Note: Arguments in Args that contain spaces and/or quotes such as
    --  "--GCC=gcc -v" or "--GCC=""gcc -v""" are not portable across all
@@ -695,12 +732,12 @@ package System.OS_Lib is
    --  "Spawn" should not be used in tasking applications.
 
    procedure Spawn
-     (Program_Name  : String;
-      Args          : Argument_List;
-      Output_File   : String;
-      Success       : out Boolean;
-      Return_Code   : out Integer;
-      Err_To_Out    : Boolean := True);
+     (Program_Name : String;
+      Args         : Argument_List;
+      Output_File  : String;
+      Success      : out Boolean;
+      Return_Code  : out Integer;
+      Err_To_Out   : Boolean := True);
    --  Similar to the procedure above, but saves the output of the command to
    --  a file with the name Output_File.
    --
@@ -814,12 +851,24 @@ package System.OS_Lib is
    --  changes made by Setenv calls. This procedure is not available on VMS.
 
    procedure OS_Exit (Status : Integer);
-   pragma Import (C, OS_Exit, "__gnat_os_exit");
    pragma No_Return (OS_Exit);
+
    --  Exit to OS with given status code (program is terminated). Note that
    --  this is abrupt termination. All tasks are immediately terminated. There
    --  are no finalization or other Ada-specific cleanup actions performed. On
-   --  systems with atexit handlers (such as Unix and Windows) are performed.
+   --  systems with atexit handlers (such as Unix and Windows), atexit handlers
+   --  are called.
+
+   type OS_Exit_Subprogram is access procedure (Status : Integer);
+
+   procedure OS_Exit_Default (Status : Integer);
+   pragma No_Return (OS_Exit_Default);
+   --  Default implementation of procedure OS_Exit
+
+   OS_Exit_Ptr : OS_Exit_Subprogram := OS_Exit_Default'Access;
+   --  OS_Exit is implemented through this access value. It it then possible to
+   --  change the implementation of OS_Exit by redirecting OS_Exit_Ptr to an
+   --  other implementation.
 
    procedure OS_Abort;
    pragma Import (C, OS_Abort, "abort");
@@ -847,7 +896,9 @@ private
    pragma Import (C, Directory_Separator, "__gnat_dir_separator");
    pragma Import (C, Current_Time, "__gnat_current_time");
 
-   type OS_Time is new Long_Integer;
+   type OS_Time is
+     range -(2 ** (Standard'Address_Size - Integer'(1))) ..
+           +(2 ** (Standard'Address_Size - Integer'(1)) - 1);
    --  Type used for timestamps in the compiler. This type is used to hold
    --  time stamps, but may have a different representation than C's time_t.
    --  This type needs to match the declaration of OS_Time in adaint.h.
@@ -858,7 +909,7 @@ private
    --  bootstrap path problems. To be changed later ???
 
    Invalid_Time : constant OS_Time := -1;
-   --  This value should match the return valud by __gnat_file_time_*
+   --  This value should match the return value from __gnat_file_time_*
 
    pragma Inline ("<");
    pragma Inline (">");