bcheck.adb, [...]: Move Name_Id, File_Name_Type and Unit_Name_Type from package Types...
[gcc.git] / gcc / ada / osint.ads
index d7c8c49a25aa8e82f7f67f659c59239bbd789968..c31220cc1c4d71f4959031376fcbba4f13df91af 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 S p e c                                  --
 --                                                                          --
---          Copyright (C) 1992-2005 Free Software Foundation, Inc.          --
+--          Copyright (C) 1992-2007, 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- --
 --                                                                          --
 ------------------------------------------------------------------------------
 
---  This package contains the low level, operating system routines used in
---  the GNAT compiler and binder for command line processing and file input
---  output.
+--  This package contains the low level, operating system routines used in the
+--  compiler and binder for command line processing and file input output.
 
-with GNAT.OS_Lib; use GNAT.OS_Lib;
-with System;      use System;
-with Types;       use Types;
+with Namet; use Namet;
+with Types; use Types;
 
-pragma Elaborate (GNAT.OS_Lib);
+with System.OS_Lib; use System.OS_Lib;
+with System;        use System;
+
+pragma Elaborate_All (System.OS_Lib);
+--  For the call to function Get_Target_Object_Suffix in the private part
 
 package Osint is
 
    Multi_Unit_Index_Character : Character := '~';
-   --  The character before the index of the unit in a multi-unit source,
-   --  in ALI and object file names. This is not a constant, because it is
-   --  changed to '$' on VMS.
+   --  The character before the index of the unit in a multi-unit source, in
+   --  ALI and object file names. This is not a constant, because it is changed
+   --  to '$' on VMS.
 
    Ada_Include_Path          : constant String := "ADA_INCLUDE_PATH";
    Ada_Objects_Path          : constant String := "ADA_OBJECTS_PATH";
@@ -59,18 +61,17 @@ package Osint is
    function Find_File
      (N : File_Name_Type;
       T : File_Type) return File_Name_Type;
-   --  Finds a source, library or config file depending on the value
-   --  of T following the directory search order rules unless N is the
-   --  name of the file just read with Next_Main_File and already
-   --  contains directiory information, in which case just look in the
-   --  Primary_Directory.  Returns File_Name_Type of the full file name
-   --  if found, No_File if file not found. Note that for the special
-   --  case of gnat.adc, only the compilation environment directory is
-   --  searched, i.e. the directory where the ali and object files are
-   --  written. Another special case is when Debug_Generated_Code is
-   --  set and the file name ends on ".dg", in which case we look for
-   --  the generated file only in the current directory, since that is
-   --  where it is always built.
+   --  Finds a source, library or config file depending on the value of T
+   --  following the directory search order rules unless N is the name of the
+   --  file just read with Next_Main_File and already contains directiory
+   --  information, in which case just look in the Primary_Directory. Returns
+   --  File_Name_Type of the full file name if found, No_File if file not
+   --  found. Note that for the special case of gnat.adc, only the compilation
+   --  environment directory is searched, i.e. the directory where the ali and
+   --  object files are written. Another special case is Debug_Generated_Code
+   --  set and the file name ends on ".dg", in which case we look for the
+   --  generated file only in the current directory, since that is where it is
+   --  always built.
 
    function Get_File_Names_Case_Sensitive return Int;
    pragma Import (C, Get_File_Names_Case_Sensitive,
@@ -147,11 +148,17 @@ package Osint is
    --  instance under DOS it adds the ".exe" suffix, whereas under UNIX no
    --  suffix is added.
 
+   function Executable_Name (Name : String) return String;
+   --  Same as above, with String parameters
+
    function File_Stamp (Name : File_Name_Type) return Time_Stamp_Type;
-   --  Returns the time stamp of file Name. Name should include relative
-   --  path information in order to locate it. If the source file cannot be
-   --  opened, or Name = No_File, and all blank time stamp is returned (this is
-   --  not an error situation).
+   --  Returns the time stamp of file Name. Name should include relative path
+   --  information in order to locate it. If the source file cannot be opened,
+   --  or Name = No_File, and all blank time stamp is returned (this is not an
+   --  error situation).
+
+   function File_Stamp (Name : Path_Name_Type) return Time_Stamp_Type;
+   --  Same as above for a path name
 
    type String_Access_List is array (Positive range <>) of String_Access;
    --  Deferenced type used to return a list of file specs in
@@ -376,12 +383,12 @@ package Osint is
    function Source_File_Stamp (N : File_Name_Type) return Time_Stamp_Type;
    --  Returns the full name/time stamp of the source file whose simple name
    --  is N which should not include path information. Note that if the file
-   --  cannot be located No_File is returned for the first routine and an
-   --  all blank time stamp is returned for the second (this is not an error
-   --  situation). The full name includes the appropriate directory
-   --  information. The source file directory lookup penalty is incurred
-   --  every single time the routines are called unless you have previously
-   --  called Source_File_Data (Cache => True). See below.
+   --  cannot be located No_File is returned for the first routine and an all
+   --  blank time stamp is returned for the second (this is not an error
+   --  situation). The full name includes appropriate directory information.
+   --  The source file directory lookup penalty is incurred every single time
+   --  the routines are called unless you have previously called
+   --  Source_File_Data (Cache => True). See below.
 
    function Current_File_Index return Int;
    --  Return the index in its source file of the current main unit
@@ -389,9 +396,9 @@ package Osint is
    function Matching_Full_Source_Name
      (N : File_Name_Type;
       T : Time_Stamp_Type) return File_Name_Type;
-   --  Same semantics than Full_Source_Name but will search on the source
-   --  path until a source file with time stamp matching T is found. If
-   --  none is found returns No_File.
+   --  Same semantics than Full_Source_Name but will search on the source path
+   --  until a source file with time stamp matching T is found. If none is
+   --  found returns No_File.
 
    procedure Source_File_Data (Cache : Boolean);
    --  By default source file data (full source file name and time stamp)
@@ -433,7 +440,9 @@ package Osint is
 
    --  Which of these three methods is chosen depends on the constraints of the
    --  host operating system. The interface described here is independent of
-   --  which of these approaches is used.
+   --  which of these approaches is used. Currently all versions of GNAT use
+   --  the third approach with a file name of xxx.ali where xxx is the source
+   --  file name.
 
    -------------------------------
    -- Library Information Input --
@@ -487,13 +496,12 @@ package Osint is
 
    function Full_Lib_File_Name (N : File_Name_Type) return File_Name_Type;
    function Library_File_Stamp (N : File_Name_Type) return Time_Stamp_Type;
-   --  Returns the full name/time stamp of library file N. N should not
-   --  include path information. Note that if the file cannot be located
-   --  No_File is returned for the first routine and an all blank time stamp
-   --  is returned for the second (this is not an error situation). The
-   --  full name includes the appropriate directory information. The library
-   --  file directory lookup penalty is incurred every single time this
-   --  routine is called.
+   --  Returns the full name/time stamp of library file N. N should not include
+   --  path information. Note that if the file cannot be located No_File is
+   --  returned for the first routine and an all blank time stamp is returned
+   --  for the second (this is not an error situation). The full name includes
+   --  the appropriate directory information. The library file directory lookup
+   --  penalty is incurred every single time this routine is called.
 
    function Lib_File_Name
      (Source_File : File_Name_Type;
@@ -523,9 +531,9 @@ package Osint is
 
    procedure Exit_Program (Exit_Code : Exit_Code_Type);
    pragma No_Return (Exit_Program);
-   --  A call to Exit_Program terminates execution with the given status.
-   --  A status of zero indicates normal completion, a non-zero status
-   --  indicates abnormal termination.
+   --  A call to Exit_Program terminates execution with the given status. A
+   --  status of zero indicates normal completion, a non-zero status indicates
+   --  abnormal termination.
 
    -------------------------
    -- Command Line Access --
@@ -562,7 +570,7 @@ private
    --  The suffix used for the target object files
 
    Output_FD : File_Descriptor;
-   --  The file descriptor for the current library info, tree or binder output
+   --  File descriptor for current library info, list, tree, or binder output
 
    Output_File_Name : File_Name_Type;
    --  File_Name_Type for name of open file whose FD is in Output_FD, the name
@@ -575,10 +583,10 @@ private
    type File_Name_Array_Ptr is access File_Name_Array;
    File_Names : File_Name_Array_Ptr :=
                   new File_Name_Array (1 .. Int (Argument_Count) + 2);
-   --  As arguments are scanned, file names are stored in this array
-   --  The strings do not have terminating NUL files. The array is
-   --  extensible, because when using project files, there may be
-   --  more files than arguments on the command line.
+   --  As arguments are scanned, file names are stored in this array The
+   --  strings do not have terminating NUL files. The array is extensible,
+   --  because when using project files, there may be more files than
+   --  arguments on the command line.
 
    type File_Index_Array is array (Int range <>) of Int;
    type File_Index_Array_Ptr is access File_Index_Array;
@@ -594,17 +602,17 @@ private
      (Fdesc : out File_Descriptor;
       Fmode : Mode);
    --  Create file whose name (NUL terminated) is in Name_Buffer (with the
-   --  length in Name_Len), and place the resulting descriptor in Fdesc.
-   --  Issue message and exit with fatal error if file cannot be created.
-   --  The Fmode parameter is set to either Text or Binary (see description
-   --  of GNAT.OS_Lib.Create_File).
+   --  length in Name_Len), and place the resulting descriptor in Fdesc. Issue
+   --  message and exit with fatal error if file cannot be created. The Fmode
+   --  parameter is set to either Text or Binary (for details see description
+   --  of System.OS_Lib.Create_File).
 
    type Program_Type is (Compiler, Binder, Make, Gnatls, Unspecified);
    --  Program currently running
    procedure Set_Program (P : Program_Type);
-   --  Indicates to the body of Osint the program currently running.
-   --  This procedure is called by the child packages of Osint.
-   --  A check is made that this procedure is not called several times.
+   --  Indicates to the body of Osint the program currently running. This
+   --  procedure is called by the child packages of Osint. A check is made
+   --  that this procedure is not called more than once.
 
    function More_Files return Boolean;
    --  Implements More_Source_Files and More_Lib_Files
@@ -613,14 +621,20 @@ private
    --  Implements Next_Main_Source and Next_Main_Lib_File
 
    function Object_File_Name (N : File_Name_Type) return File_Name_Type;
-   --  Constructs the name of the object file corresponding to library
-   --  file N. If N is a full file name than the returned file name will
-   --  also be a full file name. Note that no lookup in the library file
-   --  directories is done for this file. This routine merely constructs
-   --  the name.
+   --  Constructs the name of the object file corresponding to library file N.
+   --  If N is a full file name than the returned file name will also be a full
+   --  file name. Note that no lookup in the library file directories is done
+   --  for this file. This routine merely constructs the name.
 
    procedure Write_Info (Info : String);
    --  Implementation of Write_Binder_Info, Write_Debug_Info and
    --  Write_Library_Info (identical)
 
+   procedure Write_With_Check (A : Address; N  : Integer);
+   --  Writes N bytes from buffer starting at address A to file whose FD is
+   --  stored in Output_FD, and whose file name is stored as a File_Name_Type
+   --  in Output_File_Name. A check is made for disk full, and if this is
+   --  detected, the file being written is deleted, and a fatal error is
+   --  signalled.
+
 end Osint;